Skip to content

Instantly share code, notes, and snippets.

@guerbai
Last active February 4, 2020 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guerbai/8adfbf918df0d03608e72c1df76bc340 to your computer and use it in GitHub Desktop.
Save guerbai/8adfbf918df0d03608e72c1df76bc340 to your computer and use it in GitHub Desktop.
csv
import csv
filename = './test.csv'
with open(filename, 'r') as f:
data_csv = csv.DictReader(f, delimiter=',')
for data in data_csv:
print (data['clip_id'])
import csv
ids_map_csv = './test.csv'
with open(ids_map_csv, 'w') as f:
writer = csv.writer(f)
writer.writerow(['old_id', 'new_id'])
with open(filename, 'r') as f:
data_csv = csv.DictReader(f, delimiter=',')
for data in data_csv:
writer.writerow([1, 2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment