Dear Rob,
This caught me out as well for a long time.
As I understand it, csv.reader is a file-reader, which iterates ONCE
over the file. There may be more elegant solutions, but I do:
import csv
ifile = open('test.csv', "r")
reader = csv.reader(ifile)
inData = []
for row in reader:
i
Dewhirst, Rob wrote:
> Thanks Matt and Lazlo. I knew I must have been missing some counter
> not being reset. Both of those options work fine.
>
> You want to do ifile.seek(0) not reader.seek(0) at least from my testing.
>
>
> On Mon, Oct 22, 2012 at 2:27 PM, Matt Williams wrote:
[snip]
Ple
On Mon, Oct 22, 2012 at 3:35 PM, Dewhirst, Rob wrote:
>
>> import csv
>> ifile = open('test.csv', "r")
>> reader = csv.reader(ifile)
>> inData = []
>> for row in reader:
>> inData.append[row]
>> ifile.close()
>>
>> you can now loop through inData to your heart's desire.
Alternatively:
On Mon, Oct 22, 2012 at 3:35 PM, Dewhirst, Rob wrote:
> Thanks Matt and Lazlo. I knew I must have been missing some counter
> not being reset. Both of those options work fine.
>
> You want to do ifile.seek(0) not reader.seek(0) at least from my testing.
>
>
> On Mon, Oct 22, 2012 at 2:27 PM, Mat
On Mon, Oct 22, 2012 at 3:28 PM, LZAntal wrote:
> On Oct 22, 2012, at 12:20 PM, "Dewhirst, Rob" wrote:
>
>> import csv
>> ifile = open('test.csv', "r")
>> reader = csv.reader(ifile)
>
> I believe csv module uses iterator so you need to run reader.seek(0) between
> the for loops
You have to rese
Thanks Matt and Lazlo. I knew I must have been missing some counter
not being reset. Both of those options work fine.
You want to do ifile.seek(0) not reader.seek(0) at least from my testing.
On Mon, Oct 22, 2012 at 2:27 PM, Matt Williams wrote:
> Dear Rob,
>
> This caught me out as well for
On Mon, Oct 22, 2012 at 3:20 PM, Dewhirst, Rob wrote:
> import csv
> ifile = open('test.csv', "r")
> reader = csv.reader(ifile)
> for row in reader:
> print row
> for row in reader:
> print row
> ifile.close()
>
> This is a simplified version of what I am trying to do - loop throug
Dewhirst, Rob wrote:
import csv
ifile = open('test.csv', "r")
reader = csv.reader(ifile)
for row in reader:
print row
for row in reader:
print row
ifile.close()
This is a simplified version of what I am trying to do - loop through
a CSV file twice. Why does the second for loop n
Hi,
On Oct 22, 2012, at 12:20 PM, "Dewhirst, Rob" wrote:
> import csv
> ifile = open('test.csv', "r")
> reader = csv.reader(ifile)
> for row in reader:
> print row
> for row in reader:
> print row
> ifile.close()
>
> This is a simplified version of what I am trying to do - loop thro