Closed SimonHH closed 1 year ago
Hi @SimonHH
I'm surprised that it's not working for you, the priority and WrongFormatError
should indeed work the way you thought about them.
The WrongFormatError
is intended to be thrown when the read
function of a given class detects that the format is quite far off from what's expected by the format definition. The BrokenFormatError
is thrown when the format looks about right but the user likely misformated something. The distinction between the two can be a bit blurry.
You can try the following:
BrokenFormatError
is thrown
from pydatview.io.file_x import FileX
FileX( 'wrongfile.dat' )
detectFormat
(in __init__.py
) and isRightFormat
(in file_format.py
) functions to debug what's happening:
from pydatview.io import detectFormat, read
format, f = detectFormat( ' somefile.dat' )
print(format)
print(f)
# or try directly:
f = read('somefile.dat')
Are you using a user defined format that is placed in the user-pydatview-io directory? (Help>About, e.g. C:\Users\XXX\AppData\Roaming\pydatview_io
)
Maybe there is a pydatview bug for userdefined formats. Let me check..
Hi @ebranlard,
that helped. I had the WrongFormatError error thrown in the toDataFrame def and not in the read def. Now this works as expected.
FYI: I add the formats not in the user-pydatview-io directory but directly in pydatview\io\ and list them in init.py
Best regards, Simon
Great! I'm glad it worked out in the end.
Hi, I have more than one file format that has the same file ending.
How do I enable reading of both formats with the format option set to auto?
I would think that the format with the higher priority is tried first and if this causes an error the next file format on the list is used to open the file. I implemented the WrongFormatError error but this only gives a popup and not the desired behavior.
Any thoughts?
Best regards, Simon