0

Hey guys, i have a problem with reading csv files. I have a csv file which i would like to read and save to a dictionary.
Preview of the file:
mpg;engine;horse;weight;accel;year;origin;cylinder
18;307;130;3504;12;70;1;8
15;350;165;3693;11,5;70;1;8
18;318;150;3436;11;70;1;8
16;304;150;3433;12;70;1;8
and so on..
The way that i would like it to save is basically for example mpg is the key, while 18,15,18,16.. are the items. (ex. mpg:18,15,17...)
I have tried to do it with and without the csv class, but i still can't make it to save the variable as a key into a dictionary. I've managed to save the entire csv file to an array, but it isn't what im after and therefore i can't post any code that would help.

Thanks in advance for all the help.

Regards

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by pyTony
0

I tried all of the sample code given on that link, but only one was a match to what i was searching, but it was a bit overcomplicated with that extra class in it (amateur in python), so im still looking for a bit more simple code..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.