I'm struggling to read lines in from a CSV and sort them into multiple different dictionaries.
ABW,Latin America & Caribbean,High income,Aruba
Are four example values in each line of the CSV. I want Aruba to be the key with the preceding three saved as a list for the dictionary value.
with open(filename, mode='r') as csv_file:
line_count = 0
for line in csv.DictReader(csv_file, ("country code", "region", "income", "name")):
print(line)
I'm not sure how to use DictReader to achieve this goal. The above code correctly sorts everything into those keys but I'm not sure how else to specify what value ends up they key and what value goes into the list.
Aruba: ['ABW','Latin America & Caribbean','High income']
That is how I want it to end up looking.