[2.5] Reading a two-column file into an array?
- From: Gilles Ganault <nospam@xxxxxxxxxx>
- Date: Tue, 31 Jul 2007 06:03:59 +0200
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
#item<TAB>item<CRLF>
p = re.compile("^(.+)\t(.+)$")
for line in textlines:
m = p.search(line)
if m:
a[i,0] = m.group(1)
a[i,1] = m.group(2)
i = i + 1
for i in a.count:
for j in 2:
print a[i,j]
=======
Thank you.
.
- Follow-Ups:
- Re: Reading a two-column file into an array?
- From: Nagarajan
- Re: [2.5] Reading a two-column file into an array?
- From: Erik Max Francis
- Re: Reading a two-column file into an array?
- Prev by Date: Free SMS from Computer Worldwide
- Next by Date: Re: [2.5] Reading a two-column file into an array?
- Previous by thread: Free SMS from Computer Worldwide
- Next by thread: Re: [2.5] Reading a two-column file into an array?
- Index(es):
Relevant Pages
|