r/learnpython•
Dew25

Working with file I/O

This is what I'm working on. I don't know how to return this list like a normal list (which would be enclosed in [ ] , right?)

Either way the return value is behaving really strangely and I have no idea what I'm doing now.

def csvReader(filename):

 records = []
 for line in open(filename):
    line = line.rstrip('\n')  # strip '\n'
    records.append(line)
    if line=='':
       continue           # ignore empty line


 return records

Posted Mar 24, 2012, 10:22 PM UTC

710
Loading comments…