AAVSO / VStar

VStar is a visualisation and analysis tool for variable star data brought to you by AAVSO
https://www.aavso.org/vstar
GNU Affero General Public License v3.0
9 stars 3 forks source link

DownloadFormatObservationSinkPlugin: Problem with "Space" delimiter #415

Closed mpyat2 closed 2 months ago

mpyat2 commented 2 months ago
  1. New Star from AAVSO Database..., T Umi, Minimum JD= 2460310.5, Maximum JD= 2460425.5
  2. Observations, Save -> Type= "Download", Delimiter= "Space", any name (like T_Umi_space_delim.txt)
  3. File Open -> Source="Download or Simple"
  4. Select the "Observations" tab and look at the "Name" column: identifiers with spaces truncated.

Possible solution: in ValidObservation.toAAVSOFormatString: use "quoteForCSVifNeeded" for all text fields (not only for comments).

    private String quoteForCSVifNeeded(String field, String delimiter) {
        return field.contains(delimiter) ? quoteForCSV(field) : field;
    }
dbenn commented 2 months ago

Hi @mpyat2, although I agree this is a good idea in principle and has probably been in the code for a long time, I'm having trouble reproducing the error. See this row with spaces in the name for example: image

mpyat2 commented 2 months ago

Hi @dbenn Could you please attach a file (space-separated) you opened?

mpyat2 commented 2 months ago

Here is my example T_Umi_space_delim.txt

And what I see after opening it: image

dbenn commented 2 months ago

Hi @dbenn Could you please attach a file (space-separated) you opened?

@mpyat2, here it is; I used the same name for the file :) T_Umi_space_delim.txt.csv

dbenn commented 2 months ago

Interesting that you see this problem and I don't on very similar builds. Windows vs Mac? Unlikely unless we're talking about CR+LF etc. od -c may provide some insights but I don't see anything immediately obvious in the file.

EDIT: see next comment below!

Very happy for you to go with your proposed solution (your code above) if you want to.

dbenn commented 2 months ago

Ah, a key difference is that I saved as CSV and you saved with space delimiters and indeed, you did say to use Delimiter= "Space". So yes, I can see why you see what you do and that quoted strings would help. So, yes, your proposed code change makes sense. Thanks!