Created
October 3, 2018 10:55
-
-
Save ah89/bf2397bb0143a955896192e3641c4334 to your computer and use it in GitHub Desktop.
Add index in big csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
input_file_path = 'soccer_clean_flat.csv' | |
output_file_name = 'soccer_clean.csv' | |
f = open(input_file_path) | |
csv_f = csv.reader(f) | |
header = csv_f.next() | |
f2 = open(output_file_name, 'w') | |
f2.write('{},{},{}\n'.format(header[0], header[1], header[2])) | |
for r in csv_f: | |
f2.write('{},{},{}\n'.format(str(int(r[0]) + 1), r[1], r[2])) | |
f.close() | |
f2.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment