Skip to content

Commit

Permalink
Automatically detect header in CSVPointsSource
Browse files Browse the repository at this point in the history
  • Loading branch information
cmalinmayor committed May 16, 2024
1 parent 6b8bfea commit 4c54298
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gunpowder/nodes/csv_points_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,18 @@ def _parse_csv(self):
data = []
ids = []
with open(self.filename, "r", newline="") as f:
has_header = csv.Sniffer().has_header(f.read(1024))
f.seek(0)
first_line = True
reader = csv.reader(f, delimiter=self.delimiter)
for line in reader:
space = [line[c] for c in self.spatial_cols]
if first_line and has_header:
first_line = False
continue
space = [float(line[c]) for c in self.spatial_cols]
data.append(space)
if self.id_dim is not None:
ids.append(line[self.id_dim])
data.append(list(map(float, space)))

self.data = np.array(data, dtype=np.float32)
if self.id_dim:
Expand Down

0 comments on commit 4c54298

Please sign in to comment.