954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Reading CSV files

Well, the title pretty much explains it,
I want to read a CSV file and print the file into a GUI Text area.
Or other suitable Widget,
while im at it is there any widget that can display csv Files in a excel sort of syle, in the sense of lots of boxes with data in each one...
or is it possible to put divisions in a textbox do with a textbox.

Gumster
Newbie Poster
6 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

To read the CSV you can use the standard open file and readlines into a list. You could then use the split command with the comma to separate the items.

items=lines.split(",")



I am not sure if this is the best way, more advanced programmers may have a better way. I am working on wxPython and the list control, which displays data in an excel style. It wasn't too difficult to get it to display data from a list.

davidjhay
Newbie Poster
12 posts since Mar 2007
Reputation Points: 10
Solved Threads: 6
 

Hi guys,

there is also a csv module for python to assist with reading and writing csv files...

http://docs.python.org/lib/csv-examples.html

hth

grobister
Newbie Poster
7 posts since Aug 2007
Reputation Points: 10
Solved Threads: 1
 

If you install wxpython and run the demo there are examples of grid displays given.

As other posters have said, use the CSV module to work with CSV as it is very flexible as well as being easy to use.

- Paddy.

paddy3118
Light Poster
35 posts since Sep 2007
Reputation Points: 21
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You