Last active
July 27, 2017 07:03
-
-
Save oshinko/c7a3775bdf510281d4a4085822f64a25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from easydict import EasyDict | |
default_reader = csv.DictReader | |
def load_tsv(path, reader=default_reader): | |
return load_csv(path, delimiter='\t', reader=reader) | |
def load_csv(path, encoding='utf8', delimiter=',', reader=default_reader): | |
result = [] | |
with open(path, encoding=encoding) as f: | |
for row in reader(f, delimiter=delimiter): | |
try: | |
row = EasyDict(row) | |
except: | |
pass | |
result.append(row) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment