Check whether files in database are the latest published files

bike_latest_files(bikedb)

Arguments

bikedb

A string containing the path to the SQLite3 database. If no directory specified, it is presumed to be in tempdir().

Value

A named vector of binary values: TRUE is files in bikedb are the latest versions; otherwise FALSE, in which case store_bikedata could be run to update the database.

Examples

data_dir <- tempdir () bike_write_test_data (data_dir = data_dir) # or download some real data! # dl_bikedata (city = 'la', data_dir = data_dir) # Remove one London file that triggers an API call which may fail tests: file.remove (file.path (tempdir(), "01aJourneyDataExtract10Jan16-23Jan16.csv"))
#> [1] TRUE
bikedb <- file.path (data_dir, 'testdb') store_bikedata (data_dir = data_dir, bikedb = bikedb)
#> Creating sqlite3 database
#> Unzipping raw data files for bo ...
#> Reading files for bo ...
#> reading file 1/3: /tmp/Rtmp88OwDl/hubway_Trips_2012.csv #> reading file 2/3: /tmp/Rtmp88OwDl/201701-hubway-tripdata.csv #> reading file 3/3: /tmp/Rtmp88OwDl/201801_hubway_tripdata.csv
#> Trips read for bo = 600
#> Unzipping raw data files for ch ...
#> Reading files for ch ...
#> reading file 1/1: /tmp/Rtmp88OwDl/Divvy_Trips_sample.csv
#> Trips read for ch = 200
#> Unzipping raw data files for dc ...
#> Reading files for dc ...
#> reading file 1/1: /tmp/Rtmp88OwDl/2017Q1-capitalbikeshare-tripdata-temp.csv
#> Trips read for dc = 200
#> Unzipping raw data files for la ...
#> Reading files for la ...
#> reading file 1/1: /tmp/Rtmp88OwDl/la_metro_gbfs_trips_Q1_2017.csv
#> Trips read for la = 198
#> Unzipping raw data files for mn ...
#> Reading files for mn ...
#> reading file 1/1: /tmp/Rtmp88OwDl/Nice_Ride_trip_history_2012_season.csv
#> Trips read for mn = 200
#> Unzipping raw data files for ny ...
#> Reading files for ny ...
#> reading file 1/1: /tmp/Rtmp88OwDl/201612-citibike-tripdata.csv
#> Trips read for ny = 200
#> Total trips read = 1,598
#> [1] 1598
# bike_latest_files (bikedb) # All false because test data are not current, but would pass with real data bike_rm_test_data (data_dir = data_dir)
#> [1] 12
bike_rm_db (bikedb)
#> [1] TRUE
# don't forget to remove real data! # file.remove (list.files (data_dir, pattern = '.zip'))