CSV Reader
Reedick, Andrew
jr9445 at ATT.COM
Mon Feb 11 11:24:14 EST 2008
> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of Mike P
> Sent: Monday, February 11, 2008 11:10 AM
> To: python-list at python.org
> Subject: Re: CSV Reader
>
> Hi Larry,
>
> i'm still getting to grips with python, but rest assured i thinkn it's
> better for me to write hte code for learnign purposes
>
> My basic file is here, it comes up with a syntax error on the
> startswith line, is this because it is potentially a list?
> My idea was to get the lines number where i can see Transaction ID and
> then write out everything from this point into a new datafile.
>
>
>From the docs for reader: "All data read are returned as strings. No
automatic data type conversion is performed."
Just use print or repr() to see what the row data looks. Then the
method to check for 'transaction id' should be abundantly clear.
for data in reader:
print data
print repr(data)
> Would a better solution be just to use readlines and search for the
> string with a counter and then write out a file from there?
Yes you could, but the danger is that you get an insanely large file
that blows out your memory or causes the process to swap to disk space
(disk is slooooooooow.)
Just loop through the lines and use a boolean flag to determine when to
start printing.
*****
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621
More information about the Python-list
mailing list