0

I'm trying to parse a csv file into individual elements using .strip and .split

for line in infile:
    line = line.rstrip('\n').split(',')
    id = int(line[0])
    name = str(line[1])
    average_user_rating = float(line[2])
    user_rating_count = int(line[3])
    developer = str(line[4])
    size = int(line[5])

But I don't think the .split(',') works for my file because there are commas in the name string.

289382458,Chess Game,3,504,Memention Holding AB,444163
290493286,Catcha Mouse,3.5,95971,"Meme, Inc",26820692
290614255,"Cool Sudoku, Jigsaw, Killer",3.5,357,Splash Software Ltd.,52236288 

"Cool Sudoku, Jigsaw, Killer". If I do .split(",") my line[2] would be ' Jigsaw' instead of 3.5. May I know are there any other way to parse these elements?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Jason Leng
  • 11
  • 3

0 Answers0