On Tue, 31 Jul 2007 08:41:45 -0700, [EMAIL PROTECTED] (Alex Martelli)
wrote:
That's what 2.5's with statement is all about...:
Thanks everyone. Python power :-)
from __future__ import with_statement
import csv
with open('import.csv', 'rb') as f:
for item in list(csv.reader(f,
On Mon, 30 Jul 2007 21:57:17 -0700, Nagarajan wrote:
a = []
import csv
reader = csv.reader(open(filename, r), delimiter='\t' )
for row in reader:
a.append( row )
I would keep a reference to the file to close it properly and the loop can
be replaced by a call to `list()`:
import csv
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Mon, 30 Jul 2007 21:57:17 -0700, Nagarajan wrote:
a = []
import csv
reader = csv.reader(open(filename, r), delimiter='\t' )
for row in reader:
a.append( row )
I would keep a reference to the file to close it properly and the
Hello
I'm sure there's a much easier way to read a two-column, CSV file into
an array, but I haven't found it in Google.
Should I use the Array module instead?
=
a = []
i = 0
#itemTABitemCRLF
p = re.compile(^(.+)\t(.+)$)
for line in textlines:
m = p.search(line)
if m:
Gilles Ganault wrote:
I'm sure there's a much easier way to read a two-column, CSV file into
an array, but I haven't found it in Google.
Should I use the Array module instead?
The csv module? Or just .rstrip and .split?
--
Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/
On Jul 31, 9:03 am, Gilles Ganault [EMAIL PROTECTED] wrote:
Hello
I'm sure there's a much easier way to read a two-column, CSV file into
an array, but I haven't found it in Google.
Should I use the Array module instead?
=
a = []
i = 0
#itemTABitemCRLF
p =
Nagarajan wrote:
On Jul 31, 9:03 am, Gilles Ganault [EMAIL PROTECTED] wrote:
Hello
I'm sure there's a much easier way to read a two-column, CSV file into
an array, but I haven't found it in Google.
Should I use the Array module instead?
[...snip]
a = []
import csv
reader =