On 2014-12-29 16:37, JC wrote:
> On Mon, 29 Dec 2014 10:32:03 -0600, Skip Montanaro wrote:
>
> > On Mon, Dec 29, 2014 at 10:11 AM, JC
> > wrote:
> >> Do I have to open the file again to get 'rdr' work again?
> >
> > Yes, but if you want the number of records, just operate on the
> > rows list, e
On 2014-12-29 16:11, JC wrote:
> On Mon, 29 Dec 2014 09:47:23 -0600, Skip Montanaro wrote:
>
> > On Mon, Dec 29, 2014 at 9:35 AM, JC wrote:
> >> How could I get the all the records?
> >
> > This should work:
> >
> > with open('x.csv','rb') as f:
> > rdr = csv.DictReader(f,delimiter=',')
> >
On Mon, 29 Dec 2014 10:32:03 -0600, Skip Montanaro wrote:
> On Mon, Dec 29, 2014 at 10:11 AM, JC wrote:
>> Do I have to open the file again to get 'rdr' work again?
>
> Yes, but if you want the number of records, just operate on the rows
> list, e.g. len(rows).
>
> Skip
Yes, I did that. But if
On Mon, Dec 29, 2014 at 10:11 AM, JC wrote:
> Do I have to open the file again to get 'rdr' work again?
Yes, but if you want the number of records, just operate on the rows
list, e.g. len(rows).
Skip
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, 29 Dec 2014 09:47:23 -0600, Skip Montanaro wrote:
> On Mon, Dec 29, 2014 at 9:35 AM, JC wrote:
>> How could I get the all the records?
>
> This should work:
>
> with open('x.csv','rb') as f:
> rdr = csv.DictReader(f,delimiter=',')
> rows = list(rdr)
>
> You will be left with a
On Mon, Dec 29, 2014 at 9:35 AM, JC wrote:
> How could I get the all the records?
This should work:
with open('x.csv','rb') as f:
rdr = csv.DictReader(f,delimiter=',')
rows = list(rdr)
You will be left with a list of dictionaries, one dict per row, keyed
by the values in the first row:
Hello,
I have csv file like:
id,name,userid,password
1,ABC,def@ghi,1234
2,DEF,ghi@jkl,asdf
3,GHI,jkl@mno,zxcv
.
.
.
I need to get that csv file into a dictionary. Here is my code:
import csv
with open('x.csv','rb') as f:
rdr = csv.DictReader(f,delimiter=',')
flds = rdr.fieldnames
r