You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
III. FORMAT OF DATA FILES (".dly" FILES)
Each ".dly" file contains data for one station. The name of the file
corresponds to a station's identification code. For example, "USC00026481.dly"
contains the data for the station with the identification code USC00026481).
Each record in a file contains one month of daily data. The variables on each
line include the following:
------------------------------
Variable Columns Type
------------------------------
ID 1-11 Character
YEAR 12-15 Integer
MONTH 16-17 Integer
ELEMENT 18-21 Character
VALUE1 22-26 Integer
MFLAG1 27-27 Character
QFLAG1 28-28 Character
SFLAG1 29-29 Character
VALUE2 30-34 Integer
MFLAG2 35-35 Character
QFLAG2 36-36 Character
SFLAG2 37-37 Character
. . .
. . .
. . .
VALUE31 262-266 Integer
MFLAG31 267-267 Character
QFLAG31 268-268 Character
SFLAG31 269-269 Character
------------------------------
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:
factor out the code in ghcnd_GET to process a fwf file to a fxn, e.g., process_fwf
use process_fwf in ghcnd_GET to replace the code just factored out
use process_fwf in ghcnd_read if the file is fwf, or simply read as comma sep format if already a csv
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
The text was updated successfully, but these errors were encountered: