BEMServer / bemserver-core

https://bemserver-docs.readthedocs.io/
MIT License
3 stars 3 forks source link

Importing several timeseries using CSV raised "Validation errors" without telling why #229

Open scls19fr opened 5 months ago

scls19fr commented 5 months ago

Hello,

I tried to import several timeseries at once using user interface but I was getting the following error

image

:x: Validation errors!

Validation errors Invalid CSV file content: Timeseries "NewTSName" can't be created.

The following CSV file was used:

Building,Site,Name,Campaign scope,Zone,Unit,Space,Storey,Description
Building3,TestSite,NewTSName,TestCampaignScope0,Zone1,Unit,Salle 1,R1,Description1

Building3,TestSite,TestCampaignScope0 have ever been created

After turning around the problem... I noticed that unit wasn't set correctly.

Maybe a more explicit error message could be raised.

An other important point to improve user experience could be to provide sample import file (so typo with columns names won't occur).

Kind regards

lafrech commented 5 months ago

Yes, it is kinda hard to report errors.

Basically, what the code does is instantiate the Timeseries object, flush it to DB and catch errors. The error message could contain the database message but it sucks to pass database error messages to the frontend. Unit validation occurs at flush time. We could catch the unit error separately, but this leaves all other errors, and those may be quite ugly for a user, for instance those related to unique constraints.

At least, we flush between each line, to the user knows which line is wrong.

Also, a poorly documented "limitation" is that units must conform to pint notation, which is generally fine but can be surprising. For instance, m2 must be written m^2.

I'm not sure what can reasonably be done here.

Indeed sample files with column headers is something feasible that we had in mind but we haven't found time for that as it is not a priority for us (we generally copy the same spreadsheet for all projects).