Robsteranium / csvwr

Read and write CSV on the Web (csvw) tables and metadata in R
https://robsteranium.github.io/csvwr
15 stars 0 forks source link

how to read from multiple csv files? #9

Open NorthernHarrier opened 11 months ago

NorthernHarrier commented 11 months ago

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

Robsteranium commented 9 months ago

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