HK3-Lab-Team / pytrousse

PyTrousse collects into one toolbox a set of data wrangling procedures tailored for composing reproducible analytics pipelines.
Apache License 2.0
0 stars 1 forks source link

`dataframe_with_info.read_file` does not raise errors if the file does not exist #29

Open lorenz-gorini opened 4 years ago

lorenz-gorini commented 4 years ago

Since shelve.open() function may be used for reading, but also for writing files, when the user wants to read a shelve file by calling dataframe_with_info.read_file function, no errors are raised if the file does not exist and a new empty file is created. This is a problem because usually this makes the function raise MultipleObjectsInFileError, but this does not explain the actual problem.

My proposal is to check if the file exists before opening it with shelve.open() function, or using theflag='r'for opening it in read-only mode (without the possibility of creating it when it does not exist), instead of the default flag='c'

alessiamarcolini commented 4 years ago

totally up for checking upfront if the file exists, so you can then handle the error explicitly