ebranlard / pyDatView

A crossplatform GUI to plot tabulated data from files (e.g. CSV, Excel, OpenFAST, HAWC2, Flex...), or python pandas dataframes
MIT License
107 stars 41 forks source link

file formats with the same extension #149

Closed SimonHH closed 1 year ago

SimonHH commented 1 year ago

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

ebranlard commented 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:

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..

SimonHH commented 1 year ago

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

ebranlard commented 1 year ago

Great! I'm glad it worked out in the end.