View Single Post
  #2 (permalink)  
Old 04-23-2007, 04:29 PM
paddy3118 paddy3118 is offline
Newbie
 
Join Date: Apr 2007
Location: UK
Posts: 6
Rep Power: 0
paddy3118 is on a distinguished road
Wink

Hi annannienann,
For CSV's I would take a good look at the csv module documentation, but, looking at your txt file input you should be able to use the .split() string method to split the input on commas, and, because this returns a list of strings, you could use a list of lists as a 2D array something like the following (untested):
Code:
txtfile = ...
data = []
for line in txtfile:
  data.append( line.rstrip().split(',') )
- Paddy.
P.S. It is not good to re-assign file - it is a Python built-in function. (Thats why I have used txtfile).
Reply With Quote