Hi,

I'm a starter of python programming and i've stuck on a problem.

i imported a csv library into the consule and i tried to print out a particular column.

but i don't want to print out the heading (which is the first row) of the column.

this is what i did at first:

# GDP/population
import urllib
file=urllib.urlopen("http://app.lms.unimelb.edu.au/bbcswebdav/courses/600151_2008_1/datasets/humanities/devidx_2001_2006.csv").readlines()
for rows in file:
GDP=rows.split(",")[20]
pop=rows.split(",")[43]
print GDP
print pop

then i think maybe i can do it in this way,

>>> import urllib
>>> import csv
>>> visitor_url = urllib.urlopen("http://app.lms.unimelb.edu.au/bbcswebdav/courses/600151_2008_1/datasets/humanities/devidx_2001_2006.csv")
>>> data = csv.reader(visitor_url)
>>> for line in data:
... print line

could anyone please help?

THANKS A LOT! :)

Use code tags and submit some sample data in raw form and how you want it to appear after formatting. There is not enough information in your post.

Hi,

I'm a starter of python programming and i've stuck on a problem.

i imported a csv library into the consule and i tried to print out a particular column.

but i don't want to print out the heading (which is the first row) of the column.

this is what i did at first:

# GDP/population
import urllib
file=urllib.urlopen("http://app.lms.unimelb.edu.au/bbcswebdav/courses/600151_2008_1/datasets/humanities/devidx_2001_2006.csv").readlines()
for rows in file:
GDP=rows.split(",")[20]
pop=rows.split(",")[43]
print GDP
print pop

then i think maybe i can do it in this way,

>>> import urllib
>>> import csv
>>> visitor_url = urllib.urlopen("http://app.lms.unimelb.edu.au/bbcswebdav/courses/600151_2008_1/datasets/humanities/devidx_2001_2006.csv")
>>> data = csv.reader(visitor_url)
>>> for line in data:
... print line

could anyone please help?

THANKS A LOT! :)

>>> for line in data:
... print line

Print the information of the line+1 ...as simple as that

Before "for line in data", set a line counter to 0. Inside the loop, increment the counter. Only when it is > 1, print the line.

This article has been dead for over six months. Start a new discussion instead.