Re: how to create a dictionary from csv file?

2016-04-27 Thread Sibylle Koczian
Am 27.04.2016 um 11:31 schrieb Peter Otten: Sibylle Koczian wrote: And if the csv module is used anyway, why not simply read into a DictReader? How would that help with looking up 3.5 by "apple" given the OP's sample data banana,4.0 apple,3.5 orange,3.0 Quite right, it wouldn't. Misread

Re: how to create a dictionary from csv file?

2016-04-27 Thread Peter Otten
Sibylle Koczian wrote: > Am 27.04.2016 um 04:42 schrieb jf...@ms4.hinet.net: >> Just curious:-) why everyone here open the csv file without using >> newline='' as suggested in Python 3.4.4 document section 14.1? Carelessness, lack of knowledge (I plead guilty), not on Windows and no embedded

Re: how to create a dictionary from csv file?

2016-04-27 Thread Sibylle Koczian
Am 27.04.2016 um 04:42 schrieb jf...@ms4.hinet.net: Just curious:-) why everyone here open the csv file without using newline='' as suggested in Python 3.4.4 document section 14.1? And if the csv module is used anyway, why not simply read into a DictReader? --

Re: how to create a dictionary from csv file?

2016-04-26 Thread jfong
Just curious:-) why everyone here open the csv file without using newline='' as suggested in Python 3.4.4 document section 14.1? -- https://mail.python.org/mailman/listinfo/python-list

Re: how to create a dictionary from csv file?

2016-04-26 Thread Hasan Diwan
>> I am learning python. >> >> if I have a csv file, like this >> banana,4.0 >> apple,3.5 >> orange,3.0 >> >> Can anyone show me how to read the csv file line by line and then >> create a dictionary to contain these keys and values? with open('data.csv') as f: data = dict([[l.strip() for l

Re: how to create a dictionary from csv file?

2016-04-26 Thread Tim Chase
On 2016-04-26 07:18, +dime+ wrote: > I am learning python. > > if I have a csv file, like this > banana,4.0 > apple,3.5 > orange,3.0 > > Can anyone show me how to read the csv file line by line and then > create a dictionary to contain these keys and values? import csv with open('data.csv') as

Re: how to create a dictionary from csv file?

2016-04-26 Thread justin walters
On Tue, Apr 26, 2016 at 7:18 AM, +dime+ wrote: > I am learning python. > > if I have a csv file, like this > banana,4.0 > apple,3.5 > orange,3.0 > > Can anyone show me how to read the csv file line by line and then create a > dictionary to contain these keys and values? > >

Re: how to create a dictionary from csv file?

2016-04-26 Thread Peter Otten
+dime+ wrote: > I am learning python. > > if I have a csv file, like this > banana,4.0 > apple,3.5 > orange,3.0 > > Can anyone show me how to read the csv file line by line and then create a > dictionary to contain these keys and values? Below is a spoiler, but learning Python is more fun and

how to create a dictionary from csv file?

2016-04-26 Thread +dime+
I am learning python. if I have a csv file, like this banana,4.0 apple,3.5 orange,3.0 Can anyone show me how to read the csv file line by line and then create a dictionary to contain these keys and values? Regards, +dime+ -- https://mail.python.org/mailman/listinfo/python-list