Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created September 24, 2021 07:01
Show Gist options
  • Save SaraM92/8fdb45b818c7a550cafe53ea171e47e2 to your computer and use it in GitHub Desktop.
Save SaraM92/8fdb45b818c7a550cafe53ea171e47e2 to your computer and use it in GitHub Desktop.
import csv
csv_mapping_list = []
with open("/path/to/data.csv") as my_data:
csv_reader = csv.reader(my_data, delimiter=",")
line_count = 0
for line in csv_reader:
if line_count == 0:
header = line
else:
row_dict = {key: value for key, value in zip(header, line)}
csv_mapping_list.append(row_dict)
line_count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment