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! :)

Recommended Answers

All 3 Replies

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

Member Avatar for kdoiron

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.