Open jonathan-g opened 3 years ago
thanks for catching that!
up for helping out by sending a PR?
I added the ghcnd_read
fxn as an afterthought not thinking it through all the way. When we download the files with ghncd()
they are in the fixed width format you describe, but then before writing them to disk we process them to make them more digestible - see https://github.com/ropensci/rnoaa/blob/master/R/ghcnd.R#L202-L223 - THEN they are written to disk in comma sep format
So probably ideally we change gchnd_read()
to read a file directly from NOAA in fixed width format AND in comma sep format (i.e., from a call to ghcnd()
) - Sound good?
So, i think we:
ghcnd_GET
to process a fwf file to a fxn, e.g., process_fwf
process_fwf
in ghcnd_GET
to replace the code just factored outprocess_fwf
in ghcnd_read
if the file is fwf, or simply read as comma sep format if already a csvI will be happy to submit a PR to fix this. It may take a little while for me to get to it, but I will be happy to do this if you're not in a hurry.
Great, not in a hurry unless CRAN maintainers get in touch about any failures, e.g. #382
Bug description
ghcnd_read
fails with an error because it expects a.dly
file to be a.csv
file, but it's a fixed-width file with no delimiters between columns.Reprex
Created on 2021-01-29 by the reprex package (v0.3.0)
This is what the first several lines of `USW00013897.dly" look like:
And this is the file format, as described in the
readme-1.txt
at the FTP site ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt:Session Info