Skip to content

Commit

Permalink
Handle leading spaces correctly #229
Browse files Browse the repository at this point in the history
  • Loading branch information
krlawrence committed Jun 30, 2022
1 parent b89a233 commit 060b387
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion csv-gremlin/csv-gremlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def process_csv_file(self,fname):
self.property_count = 0
try:
with open(fname, newline='') as csvfile:
reader = csv.DictReader(csvfile,escapechar="\\")
reader = csv.DictReader(csvfile, skipinitialspace=True, escapechar="\\")

if not '~id' in reader.fieldnames:
self.print_error('The header row must include an ~id column')
Expand Down
3 changes: 3 additions & 0 deletions csv-gremlin/test-files/header-with-spaces-edge.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
~id, ~label, ~from, ~to
e1, likes, a1, a2
e2, " likes ", a1, a2
4 changes: 4 additions & 0 deletions csv-gremlin/test-files/header-with-spaces.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
~id, ~label, type
a1, animal, cat
a2, " animal ", cat
a3, animal , cat

0 comments on commit 060b387

Please sign in to comment.