File size: 725 Bytes
9be4956
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
# print now directory
print(os.getcwd())
state_set = set()
city_set = set()
with open('database/background/citySet_with_states.txt','r') as f:
    city_set = f.read().strip().split('\n')
    for city in city_set:
        city_name = city.split('\t')[0]
        state_name = city.split('\t')[1]
        state_set.add(state_name)
        city_set.add(city_name)
        # write to new file
    f.close()
# with open('database/background/stateSet.txt', 'a') as f:
#     for state_name in state_set:
#         f.write(state_name.split('\\')[0] + '\n')
#     f.close()
with open('database/background/citySet_2.txt', 'a') as f:
    for city_name in city_set:
        f.write(city_name.split('\\')[0] + '\n')
    f.close()