FileReader #5

Merged
bacant150 merged 15 commits from lab1_huranets into lab1 2026-02-26 10:04:10 +02:00
Showing only changes of commit e4be6b0a19 - Show all commits

View File

@@ -109,6 +109,7 @@ class FileDatasource:
raise RuntimeError("Accelerometer file is not open.")
self._acc_f.seek(0)
self._acc_reader = csv.reader(self._acc_f, skipinitialspace=True)
VladiusVostokus commented 2026-02-25 11:14:51 +02:00 (Migrated from github.com)
Review

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)

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)
VladiusVostokus commented 2026-02-25 11:15:57 +02:00 (Migrated from github.com)
Review

And do the same for other rewinders

And do the same for other rewinders
bacant150 commented 2026-02-25 12:02:34 +02:00 (Migrated from github.com)
Review

Refactoring file rewind logic to skip header line after seek(0) and for other rewinders

Refactoring file rewind logic to skip header line after seek(0) and for other rewinders
next(self._acc_reader) # Skip header row
_, self._acc_buf = self._detect_header_and_buffer(
self._acc_reader, expected_cols=3, header_tokens=("x", "y", "z")
VladiusVostokus commented 2026-02-25 15:52:46 +02:00 (Migrated from github.com)
Review

Why leave _ here if it's not used?
Maybe dont return anything from this method?

Why leave _ here if it's not used? Maybe dont return anything from this method?
VladiusVostokus commented 2026-02-25 16:00:51 +02:00 (Migrated from github.com)
Review

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?
bacant150 commented 2026-02-25 20:57:57 +02:00 (Migrated from github.com)
Review

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.

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.")
self._gps_f.seek(0)
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_reader, expected_cols=2, header_tokens=("longitude", "latitude")
)