Re: Reading a two-column file into an array?
- From: Marc 'BlackJack' Rintsch <bj_666@xxxxxxx>
- Date: 31 Jul 2007 06:03:55 GMT
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
def main():
data_file = open('filename', 'rb')
a = list(csv.reader(data_file, delimiter='\t'))
data_file.close()
Ciao,
Marc 'BlackJack' Rintsch
.
- Follow-Ups:
- Re: Reading a two-column file into an array?
- From: Alex Martelli
- Re: Reading a two-column file into an array?
- References:
- [2.5] Reading a two-column file into an array?
- From: Gilles Ganault
- Re: Reading a two-column file into an array?
- From: Nagarajan
- [2.5] Reading a two-column file into an array?
- Prev by Date: Re: Why no maintained wrapper to Win32?
- Next by Date: Re: Pysqlite storing file as blob example
- Previous by thread: Re: Reading a two-column file into an array?
- Next by thread: Re: Reading a two-column file into an array?
- Index(es):
Relevant Pages
|