spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
73 stars 18 forks source link

Spine DB support for more delimiters #1295

Open tltoni opened 3 years ago

tltoni commented 3 years ago

Request: Support for other delimiters like comma if we copy-paste tables to Spine DB.

Currently tab is used as a delimiter for copy pasting values to tables in Spine DB. For example, in the tutorial this is extensively used, see: https://spine-toolbox.readthedocs.io/en/latest/case_study_a5.html

The issue is that tabs are treated differently in different text editors and other software. A more robust way would be to support also other delimiters, e.g. comma. In this case copy-pasting would be possible from comma separated value (CSV) files, which would be more robust. An example of this issue is that .rst don't support tabs, hence, the given tutorial examples all copy pasting from tables must happen by including external text files in order for copy pasting to work. Additionally, it's difficult if not impossible to nicely align a table with entries of different lengths by using tabs.

Below is a part of table that the user is required to copy

Rebnis_pwr_plant Rebnis_upper Sadva_pwr_plant Sadva_upper Bergnäs_pwr_plant Bergnäs_upper Slagnäs_pwr_plant Slagnäs_upper

Here copy pasting works, but the table looks weird. A support for other delimiters like comma would resolve the issue, e.g. if copy pasting of the following would work: Rebnis_pwr_plant , Rebnis_upper Sadva_pwr_plant , Sadva_upper Bergnäs_pwr_plant , Bergnäs_upper Slagnäs_pwr_plant , Slagnäs_upper

Note, it seems that the above shown example does not work because tabs and spaces are removed. However, this emphasis the issue that relying on tabs when copy pasting tables is not a robust way to go.

For convenience a spine model example is attached.

Case Study A5.zip

soininen commented 1 year ago

We could try to use csv package's Sniffer to autodetect the 'dialect'.