R (Language) + API? Any examples?

Affiliation
American Association of Variable Star Observers (AAVSO)
Mon, 03/02/2020 - 01:24

Does anyone have a example of using the API with R? I keep gettting errors about the number of fields? TIA David

Affiliation
American Association of Variable Star Observers (AAVSO)
Eric,

Eric,

Thanks for following up on my post.

I'm wanting to download the observation data(csv or tab) like I can get from here:

https://www.aavso.org/data-download

The problem(s) try to download ( and webpage)using " Comma-delimited " because the text fields(and col headings ) are not "quoted" so R is reading  "Comp Star 1" as "Comp" and "Star 1" or some conbination? Interesting enough if you use the " Tab-delimited" file the field names and text data is "quoted"? Here the statement I've been tying to use:

https://www.aavso.org/vsx/index.php?view=api.delim&ident="STAR"&fromjd=DATE1&tojd=DATE2&delimiter=,

 

Thanks again,

David

Affiliation
Vereniging Voor Sterrenkunde, Werkgroep Veranderlijke Sterren (Belgium) (VVS)
Which API?

Hi David,

You may be confusing things.  If you use the api url you specified above, the format is completely different from what you get from the https://www.aavso.org/data-download page. For instance, the header returned by api.delim does not contain spaces.  That api was specifically added because some people didn't want to handle quoted fields.  So they get to choose their own delimiter without quoted fields.  If you want a "proper" csv format, use api.csv: it returns comma separated fields with some fields quoted if they may contain a comma. But again, all this is independent from the format you get from https://www.aavso.org/data-download.

Patrick

Affiliation
American Association of Variable Star Observers (AAVSO)
Delimiters

I think you've mixed up your forum threads.

I try never to use Tab-delimited csv files. You can't see them so they're easy to skip or duplicate, and they don't always play nicely with quote marks (data strings).

Also, I try never to use comma-delimited csv files (I know, I know, that's what CSV means, but anyway). Comma delimiters are a catastrophe for certain AAVSO data feeds that include commas in observer name fields, e.g., "Dose, Eric".

When I have a choice, I use semi-colon delimiters. Easy to read, rarely used in data strings, and universally accepted by Excel, etc. The vertical or-sign "|" is my next choice should semi-colon not be available. In one AAVSO feed case (I forget which) I even used "@@@" as delimiter, out of desperation. Worked fine, but multi-character delimiters are suboptimal and a last resort of course.

EDIT: Also, in star name fields, space characters can be a problem. It's probably best to replace spaces with the code "%20" as "ST%20Tri". Sometimes you can substitute "+" for a space, as "ST+Tri". It just takes a minute to experiment for each data feed, and once you find the right substitution it will likely always work.

EDIT the Second: I coded in R for years, but in 2016-7 I ported all my code to python, where the astronomy support has become much, much better. R has some nice packages, but I would say that even there, python has since surpassed R in everything but econometrics and perhaps in plotting.

Affiliation
American Association of Variable Star Observers (AAVSO)
Eric,

Eric,

Thanks for you comments.

So guess is when is the AAVSO going to add qoutes around (at least) field names in the header? If they can do it with tabs they should be able to use it with commas?

Is the  delimiter=,  the output seperator?

 

David