I have csv file with 4 columns and would like to create a python list of arrays, with each csv row being an array.
I am able to get each row as an array but the problem is that the array begins and ends with quotes.
cvs data format:
User Link,Reputation,DisplayName,Location
353410,"47245","John Doe","Uruguay"
927034,"46782","Jane Doe","Bahia Blanca, Argentina"
This is one of the codes I tried:
with open('Query_SO_Arg.csv', 'rb') as csvfile:
so = csv.reader(csvfile, delimiter=',', quotechar='"')
so_data = []
so.next()
for row in so:
so_data.append(row)
print so_data
This is the output I am getting:
[['353410,"47245","John Doe","Uruguay";'], ['927034,"46782","Jane Doe","Bahia Blanca, Argentina";'], ['62024,"41775","Jim Doe","Buenos Aires, Argentina";'],
How can I build this structure but without the external '' so I can work with the data?
Thanks!
EDIT:
This is the data of a brand new csv file (with the same structure as the original one):
User Link,Reputation,DisplayName,Location
60000,"40000","Diego K","Buenos Aires, Argentina"
240000,"37000","Claudio R","Buenos Aires, Argentina"
This is the output I am getting (with the same old quote problem):
[['60000,"40000","Diego K", "Buenos Aires, Argentina"'], ['240000,"37000","Claudio R","Buenos Aires, Argentina"']]
EDIT 2 if I use the following code:
so = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in so:
print ', '.join(row)
I get:
User Link, Reputation, DisplayName, Location
60000,"40000","Diego K","Buenos Aires, Argentina"
240000,"37000","Claudio R","Buenos Aires, Argentina"
The data seems to be ok with the exception that there are no lists. Does this give any clue of why I cannot make the move to building lists properly?
EDIT 3: Per @MartijinPieters kind request I am posting the following code:
print repr(open('So_fake_data_test.csv', 'rb').read())
which outputs:
'User Link,Reputation,DisplayName,Location\r\n"60000,""40000"",""Diego K"",""Buenos Aires, Argentina"""\r\n"240000,""37000"",""Claudio R"",""Buenos Aires, Argentina"""\r\n'
Thanks @MartijinPieters
EDIT 4

I hope this helps. Thanks again.
list(csv.reader(csvfile))to get your list of lists; the default dialect configuration is enough.