csvwr icon indicating copy to clipboard operation
csvwr copied to clipboard

how to read from multiple csv files?

Open NorthernHarrier opened this issue 2 years ago • 1 comments

Is there a way to read multiple csv files with one metadata json file?

NorthernHarrier avatar Nov 30 '23 21:11 NorthernHarrier

Yes the spec lets you specify a csvw:TableGroup which is effectively just:

{ "tables": [{"url": "1.csv"}, {"url": "2.csv"}] }

The CSVW tests provide an example:

> countries <- read_csvw("https://github.com/Robsteranium/csvwr/blob/master/tests/csvw-tests/countries.json")

> countries$tables[[1]]$dataframe
  countryCode latitude longitude                 name
1          AD 42.54624  1.601554              Andorra
2          AE 23.42408 53.847818 United Arab Emirates
3          AF 33.93911 67.709953          Afghanistan

> countries$tables[[2]]$dataframe
  countryRef year population
1         AF 1960    9616353
2         AF 1961    9799379
3         AF 1962    9989846

Robsteranium avatar Jan 18 '24 13:01 Robsteranium