FileReader #5
@@ -109,6 +109,7 @@ class FileDatasource:
|
|||||||
raise RuntimeError("Accelerometer file is not open.")
|
raise RuntimeError("Accelerometer file is not open.")
|
||||||
self._acc_f.seek(0)
|
self._acc_f.seek(0)
|
||||||
self._acc_reader = csv.reader(self._acc_f, skipinitialspace=True)
|
self._acc_reader = csv.reader(self._acc_f, skipinitialspace=True)
|
||||||
|
|
|||||||
|
next(self._acc_reader) # Skip header row
|
||||||
_, self._acc_buf = self._detect_header_and_buffer(
|
_, self._acc_buf = self._detect_header_and_buffer(
|
||||||
self._acc_reader, expected_cols=3, header_tokens=("x", "y", "z")
|
self._acc_reader, expected_cols=3, header_tokens=("x", "y", "z")
|
||||||
|
Why leave _ here if it's not used? Why leave _ here if it's not used?
Maybe dont return anything from this method?
As I see this method doesn't modify any class fiels, so maybe just remove this method? As I see this method doesn't modify any class fiels, so maybe just remove this method?
The _detect_header_and_buffer method was not modifying any class state and its return value was unused. The _detect_header_and_buffer method was not modifying any class state and its return value was unused.
I removed the method and simplified the logic.
|
|||||||
)
|
)
|
||||||
@@ -118,6 +119,7 @@ class FileDatasource:
|
|||||||
raise RuntimeError("GPS file is not open.")
|
raise RuntimeError("GPS file is not open.")
|
||||||
self._gps_f.seek(0)
|
self._gps_f.seek(0)
|
||||||
self._gps_reader = csv.reader(self._gps_f, skipinitialspace=True)
|
self._gps_reader = csv.reader(self._gps_f, skipinitialspace=True)
|
||||||
|
next(self._gps_reader) # Skip header row
|
||||||
_, self._gps_buf = self._detect_header_and_buffer(
|
_, self._gps_buf = self._detect_header_and_buffer(
|
||||||
self._gps_reader, expected_cols=2, header_tokens=("longitude", "latitude")
|
self._gps_reader, expected_cols=2, header_tokens=("longitude", "latitude")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user
you can just skip first row after seek(0) knowing that this is a header, not actual value,
so you can write like
self._acc_f.seek(0)
self._acc_reader = csv.reader(self._acc_f)
next(self._acc_reader)
row = next(self.acc_reader)
And do the same for other rewinders
Refactoring file rewind logic to skip header line after seek(0) and for other rewinders