Skip to content

Commit

Permalink
Merge branch '100-new-powerxrd-reader' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Oct 12, 2024
2 parents 05b1136 + b0f514d commit 3ca523c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions converter_app/readers/uxd_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ def __init__(self, file: File):
self._file_extensions = ['.uxd']
self._table = None
self._version = 2
self._max_table_length = 0

def check(self):
return self.file.suffix.lower() in self._file_extensions

def _read_data(self, line: str):
if self._version == 2:
try:
for value in [self.as_number(x.strip()) for x in line.split(' ') if x != '']:
self._table['rows'].append([value])
new_row = [self.as_number(x.strip()) for x in line.split(' ') if x != '']
if len(new_row) > 0:
self._max_table_length = max(self._max_table_length, len(new_row))
self._table['rows'].append(new_row)
except ValueError:
pass
elif self._version == 3:
Expand All @@ -47,8 +50,6 @@ def _add_metadata(self, key, val):

def prepare_tables(self):
tables = []
tables = []
# xml_str = re.sub(r'\sxmlns\s*([:=])', r' xmlns_removed\g<1>', self.file.string)
self._table = self.append_table(tables)
data_rows = []
for row in self.file.fp.readlines():
Expand All @@ -71,6 +72,10 @@ def prepare_tables(self):
for row in data_rows:
self._read_data(row)

for row in self._table['rows']:
while len(row) < self._max_table_length:
row.append('')

if 'START' in self._table['metadata'] and 'STEPSIZE' in self._table['metadata']:
end = self.as_number(self._table['metadata']['START']) + (
self.as_number(self._table['metadata']['STEPSIZE']) * (len(self._table['rows']) - 1))
Expand Down
Loading

0 comments on commit 3ca523c

Please sign in to comment.