Skip to content

Instantly share code, notes, and snippets.

@Hootrix Hootrix/ forked from HintikkaKimmo/
Last active Aug 17, 2019

What would you like to do?
handy way to read csv files with unknown csv dialect
import csv
import pprint
# opens csv file and assingns it to an object
with open('data-text.csv') as csvfile:
# Use Sniffer to figure out csv dialect
dialect = csv.Sniffer().sniff(
# pass the dialect to filereader to read the file
reader = csv.reader(csvfile, dialect)
# print(dialect)
# Use for loop to print csv row by row
for row in reader:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.