Skip to content

Instantly share code, notes, and snippets.

@heronyang
Created June 24, 2019 00:30
Show Gist options
  • Select an option

  • Save heronyang/3ec2d8bc2c5ba1b5d2bb6e41cc9f0a71 to your computer and use it in GitHub Desktop.

Select an option

Save heronyang/3ec2d8bc2c5ba1b5d2bb6e41cc9f0a71 to your computer and use it in GitHub Desktop.
INPUT = "merged_traffic_data.csv"
OUTPUT = "merged_traffic_data_for_fusion.csv"
with open(INPUT) as fin:
with open(OUTPUT, 'w') as fout:
is_first_line = True
for line in fin:
if is_first_line:
fout.write(',location,death,injury,time\n')
is_first_line = False
continue
s = line.split(',')
s[1] = '"' + s[1]
s[2] = s[2] + '"'
fout.write(','.join(s))
print('Done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment