CSV sniffing
This commit is contained in:
parent
5328352d4a
commit
df0ee95030
|
@ -148,7 +148,9 @@ def normalize_dict(d: dict[str,typing.Any]) -> frozendict[str,typing.Any]:
|
||||||
def load_csv_file(csv_file: Path) -> list[frozendict]:
|
def load_csv_file(csv_file: Path) -> list[frozendict]:
|
||||||
dicts: list[frozendict] = []
|
dicts: list[frozendict] = []
|
||||||
with open(csv_file) as csvfile:
|
with open(csv_file) as csvfile:
|
||||||
reader = csv.DictReader(csvfile, dialect=CSV_DIALECT)
|
dialect = csv.Sniffer().sniff(csvfile.read(1024))
|
||||||
|
csvfile.seek(0)
|
||||||
|
reader = csv.DictReader(csvfile, dialect=dialect)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
for k in list(row.keys()):
|
for k in list(row.keys()):
|
||||||
orig = row[k]
|
orig = row[k]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user