[Tutor] Parsing data from a csv file
joel.goldstick at gmail.com
Thu Mar 24 14:24:54 CET 2011
On Thu, Mar 24, 2011 at 8:34 AM, louis leichtnam <l.leichtnam at gmail.com>wrote:
> I am to extract a csv file from the web and parse it in python and after
> that make it into an html page.
> I want to get the data out of the csv file, get rid of the "," and make it
> I would like to be able to print the line I want but I don't know how to do
> I would like to modify some lines, and make them cleaner
> Can you help me?
> import urllib, csv
> for char,meal,ate,qty,com in reader:
at this point you have the five fields you want
if you do print char, meal, ate, qty,com you will see your data with the
> for x in char:
> for y in meal:
> for z in ate:
> for aa in qty:
> for bb in com:
> for i in range(1::):
> print a[i]+b[i]+c[i]+d[i]+e[i]
These for loops puzzle me. It looks like you are iterating over each
character in each variable, then creating a list containing each character.
I don't think you want to do that.
The for i in range(1::): will give you an error. The range parameter needs
to be something with a length, like a string, or a list, or a tuple.
Can you show a little bit of your data file, and give us the traceback and
output of your program?
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor