I found this method for converting a csv to a list somewhere. I can't
take credit for it, I don't remember where I got it, but it helped me
out a ton.
def csv2list(csvString):
return [row.split(",") for row in csvString.split("\n")]
That should turn something like this:
asdf, asdf, asdf, asdf,\n
asdf, asdf, asdf, asdf,\n
into this:
[ ['asdf', 'asdf', 'asdf', 'asdf']
['asdf', 'asdf', 'asdf', 'asdf'] ]
To bring in the csv file I just use this:
f = open("whateverfile.csv", "rb")
lines = f.read()
f.close()
lines = csv2list(lines)
something to remember is if your other separated text has commas in
it, it will have troubles. In that case you could use an escaped comma
like so:
def csv2list(csvString):
return [row.split("\,") for row in csvString.split("\n")]
Hopefully this is a good starting point.
On Jul 24, 3:45 am, NItin <
nitipa...@gmail.com> wrote:
> Hiall