Commit fd6e2563 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

parses.py: improve csv parser

parent 2d1d0811
......@@ -88,13 +88,21 @@ def parse_csv(f, directed, params):
sniffer = csv.Sniffer()
dialect = sniffer.sniff(sample)
ft.seek(0)
eprops = params.pop("props", None)
has_header = sniffer.has_header(sample)
if eprops == "header" and has_header:
reader = csv.reader(ft, dialect=dialect)
row = next(reader)
eprops = row[2:]
ft.seek(0)
g = load_graph_from_csv(ft, hashed=True,
hash_type="string",
eprop_names=params.pop("props", None),
skip_first=sniffer.has_header(sample),
csv_options=dict(dict(dialect=dialect),
**params))
eprop_names=eprops,
skip_first=has_header,
csv_options=dict(dialect=dialect))
g.set_directed(directed)
return g
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment