I am trying to create my first parser for parsing some custom CSV files (few lines of header including meta data, followed by measurement data in table form).
I started from this template: GitHub - nomad-coe/nomad-parser-plugin-example: This is an example for NOMAD parser plugins. It should be forked to create actual plugins. and basically just changed the name “example” to “ex” everywhere for now.
First tests with just using a simple text file worked fine using the described local testing procedure (
nomad parse tests/data/test.ex.txt --show-archive)
When changing the test file from a plain text to a CSV I changed:
mainfile_name_re: ^.*\.ex\.txt$ to
tests/data/test.ex.csv (comma-separation in all lines).
parser.py I included this:
class ExParser(MatchingParser): def __init__(self): print('ExParser initialization') super().__init__( name='parsers/ex', mainfile_mime_re=r'application/csv') def parse(...): ...
I get the following error:
AssertionError: there is no parser matching test.ex.csv
When inspecting the nomad library, I can see that the input file is tested against my custom parser (
parsers/ex) however the match fails in the
is_mainfile method of
self.mainfile_mime_re still evaluates to
re.compile('text/.*') according to its default value while the input mime type is now correctly recognized as
application/csv (using the previous text file or just including a single empty line in the beginning of the csv file changes the recognized mime type to
It seems there is no object of my custom parser class ´ExParser´ instantiated actually applying the
mainfile_mime_re=r'application/csv' assignment in the
__init__ function for the
MatchingParser class. What am I missing?
Thank you very much,