Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107656
| From | justin walters <walters.justin01@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: how to create a dictionary from csv file? |
| Date | 2016-04-26 07:51 -0700 |
| Message-ID | <mailman.110.1461682290.32212.python-list@python.org> (permalink) |
| References | <246c571e-1793-4aa6-9405-19d7a1355598@googlegroups.com> <CAO1D73HaJWaD5KPw5+c4grEwVYPmYhJPxQeX_F9Ng4S54xvNrg@mail.gmail.com> |
On Tue, Apr 26, 2016 at 7:18 AM, +dime+ <donald.ng@gmail.com> 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? > > > Regards, > +dime+ > -- > https://mail.python.org/mailman/listinfo/python-list > It's best if you look up how to do this in the docs yourself. An even better way would be to think about the steps necessary to do this and then writing them down in pseudo-code. After that you can look up the functions/tools that will help you accomplish this task. One of the most important skills a programmer can have is called 'algorithmic thinking'. That is, essentially, the ability to break a problem down into smaller pieces in order to eventually solve it. So, think about this: What steps do you need to take to turn this csv file into a Python dictionary object? Imagine that you were going to do this by hand. How would you do it?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to create a dictionary from csv file? "+dime+" <donald.ng@gmail.com> - 2016-04-26 07:18 -0700
Re: how to create a dictionary from csv file? Peter Otten <__peter__@web.de> - 2016-04-26 16:40 +0200
Re: how to create a dictionary from csv file? justin walters <walters.justin01@gmail.com> - 2016-04-26 07:51 -0700
Re: how to create a dictionary from csv file? Tim Chase <python.list@tim.thechases.com> - 2016-04-26 09:36 -0500
Re: how to create a dictionary from csv file? Hasan Diwan <hasandiwan+usenet@gmail.com> - 2016-04-27 00:36 +0000
Re: how to create a dictionary from csv file? jfong@ms4.hinet.net - 2016-04-26 19:42 -0700
Re: how to create a dictionary from csv file? Sibylle Koczian <nulla.epistola@web.de> - 2016-04-27 11:10 +0200
Re: how to create a dictionary from csv file? Peter Otten <__peter__@web.de> - 2016-04-27 11:31 +0200
Re: how to create a dictionary from csv file? Sibylle Koczian <nulla.epistola@web.de> - 2016-04-27 17:37 +0200
Re: how to create a dictionary from csv file? Sibylle Koczian <nulla.epistola@web.de> - 2016-04-27 17:37 +0200
csiph-web