SCRUM-98 file reader #13
@@ -17,6 +17,10 @@ class FileReader:
|
||||
self.file_reader = reader(self.file)
|
||||
file_header = next(self.file_reader)
|
||||
|
||||
self.x_idx = file_header.index('X')
|
||||
self.y_idx = file_header.index('Y')
|
||||
self.z_idx = file_header.index('Z')
|
||||
|
||||
def stopReading(self, *args, **kwargs):
|
||||
if self.file:
|
||||
self.file.close()
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user
This function is prone to crashing on unexpected file lines. Instead of trying to adapt to a specific file format, it might be better to use try/catch and deciding what to do based on that. The code may look like so:
This way, in case the file is structured differently, has gaps or other mistakes, the function will silently skip over them and return the next valid group of values.
As an improvement, it may be way better to create a custom reader rather than relying on the csv.reader to make the script resilient against any possible .csv file failures
Ok, I'll try it