danforthcenter / plantcv

Plant phenotyping with image analysis
Mozilla Public License 2.0
655 stars 264 forks source link

Save results in CSV format without overwriting the file #886

Open nfahlgren opened 2 years ago

nfahlgren commented 2 years ago

Is your feature request related to a problem? Please describe. plantcv.outputs.save_results will add data to an existing JSON file but it overwrites an existing CSV file. If you want to combine results from multiple PlantCV workflows, from multiple Jupyter notebooks for example, you currently need to save multiple CSV files and then combine them (@josectovar brought this to our attention).

Describe the solution you'd like We could open the CSV file with mode="a" (append) instead of overwrite. We would need to exclude the header if the file exists to avoid duplicating it when adding results. We would have to assume that new observations are named uniquely relative to data already in the output file.

Describe alternatives you've considered We could potentially read the existing data as a dataframe and append the new data as a dataframe and save the merged dataframe as CSV.

afinit commented 1 year ago

Came up with one solution in #1225 but it needs some discussion