Skip to content

Instantly share code, notes, and snippets.

@travis23
Created January 9, 2020 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travis23/8131579a52e2790e65c58dd9e9377600 to your computer and use it in GitHub Desktop.
Save travis23/8131579a52e2790e65c58dd9e9377600 to your computer and use it in GitHub Desktop.
[Read csv with Python] #python #csv #null
# See https://stackoverflow.com/questions/7894856/line-contains-null-byte-in-csv-reader-python
with open(path_to_csv_file) as f:
reader = csv.reader((x.replace('\0', '') for x in f), delimiter=',') # Handle null values
while True:
try:
line = next(reader)
except StopIteration:
break
print(line) # process lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment