Problem: Dr. Hessl asked Cynthia to download all the tree ring data for the US from the International Tree Ring Data Bank (ITRDB) and provide a summary of the data available to compare to Cynthia's dissertation data. Cynthia is smart and has decided to solve the problem for WV first.
ITRDB files have a lot of metadata in the headers, but not all files have them and they are not always formatted the same way. To help her get started summarizing the available data, Cynthia wants to know which files have headers and which do not.
Data: Accessible as text files from NOAA Maintained International Tree Ring Data Bank https://www1.ncdc.noaa.gov/pub/data/paleo/treering/measurements/northamerica/usa/
- Downloads all the .rwl files for WV from the NOAA website.
- Creates a file called sitename.txt that is a list of the site names each followed by the first line of each file, which is often but not always a header with metadata, such as for
wv004
:
wv004
NERI 1 New River Gorge PIVI
- Be sure to make the paths absolute so that I can reproduce the structure on my machine simply by running your code.
- Code should be saved as part of a .md file
- Code blocks include only commands
- Comments are made around the text block in well-formatted markdown.
- The fewer lines of code, the better the answer. Edit your answer until only what is required is present. 8 lines or less is possible.
Use wget
combined with a wildcard to get all the .rwl
files for a state
Loop through those files to extract the header using cut
and head