9951 explained code solutions for 126 technologies


pythonHow to parse CSV


from io import StringIO
import csv

reader = csv.reader(StringIO('some,csv,string'))

for row in reader:
  print(row)ctrl + c
StringIO

creates IO handler from string

csv

module to manipulate CSV

csv.reader

parses CSV from given IO handler (string IO handler in our case)

some,csv,string

example csv string

for row in reader

iterate through each row in our CSV structure