-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extends CSV Reader
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
|
||
from converter_app.readers.helper.reader import Readers | ||
from converter_app.readers.csv_reader import CSVReader | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class UvvisReader(CSVReader): | ||
""" | ||
Uvvis Reader class. It extends converter_app.readers.ascii.CSVReader | ||
""" | ||
|
||
identifier = 'uvvis_reader' | ||
priority = 10 | ||
|
||
def __init__(self, file): | ||
super().__init__(file) | ||
self.metadata_lines = None | ||
self.lines = None | ||
self.rows = None | ||
|
||
def check(self): | ||
""" | ||
:return: True if it fits | ||
""" | ||
result = super().check() | ||
if result: | ||
metadata_begin = self.lines[-2] | ||
return 'Properties' in metadata_begin | ||
|
||
return result | ||
|
||
def prepare_tables(self): | ||
tables = super().prepare_tables() | ||
metadata_content = self.lines[-1] | ||
key = '' | ||
value = '' | ||
for s in metadata_content.split('\t'): | ||
if '#' in s: | ||
key = s[5:] | ||
else: | ||
value = s | ||
tables[0]['metadata'][key] = value | ||
return tables | ||
|
||
|
||
Readers.instance().register(UvvisReader) |