I did a few searches, but most of the answers are about reading the full csv file, and none of them look like the problem I am facing.
I am trying to read a file from the network using urllib2:
request = urllib2.Request('http://.../tv.txt')
response = urllib2.urlopen(request)
lines = response.readlines()
for line in lines:
...
The line format is as follows:
"ABC", "XYZ,MNO", "KLM"
"ABC", "MN"
"ABC", "123", "10", "OPPA GANGNAM STYLE", "LADY"
As you can see above, these lines are not CSV lines. The number of columns is changing.
Is there a way to split each line into a list? The result of the desire should be:
["ABC", "XYZ,MNO", "KLM"]
["ABC", "MN"]
["ABC", "123", "10", "OPPA GANGNAM STYLE", "LADY"]
I tried using line.split (","), but it cannot be broken correctly, because there is a comma inside each pair of double quotes.
Please help me if you know how to do this. Thank you very much.
Greetings
PHP-Python-Java-MySQL-newbie.