Delete database/googleDistanceMatrix/clean_data.py
Browse files
database/googleDistanceMatrix/clean_data.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
import re
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import csv
|
| 4 |
-
|
| 5 |
-
def extract_before_parenthesis(s):
|
| 6 |
-
match = re.search(r'^(.*?)\([^)]*\)', s)
|
| 7 |
-
return match.group(1) if match else s
|
| 8 |
-
|
| 9 |
-
if __name__ == '__main__':
|
| 10 |
-
data = pd.read_csv('/home/xj/toolAugEnv/code/toolConstraint/database/googleDistanceMatrix/distance.csv')
|
| 11 |
-
data = data.to_dict(orient = 'split')
|
| 12 |
-
fieldnames = ['origin', 'destination', 'cost', 'duration', 'distance']
|
| 13 |
-
with open('/home/xj/toolAugEnv/code/toolConstraint/database/googleDistanceMatrix/distance2.csv', 'w', newline='') as csvfile:
|
| 14 |
-
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
| 15 |
-
writer.writeheader()
|
| 16 |
-
for row in data['data']:
|
| 17 |
-
writer.writerow({'origin': extract_before_parenthesis(row[0]), 'destination': extract_before_parenthesis(row[1]), 'cost': row[2], 'duration': row[3], 'distance': row[4]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|