BBBikeReader.read_csv_xz
- BBBikeReader.read_csv_xz(subregion_name, data_dir=None, download=False, verbose=False, **kwargs)[source]
Read a compressed CSV (.csv.xz) data file of a geographic (sub)region.
- Parameters:
subregion_name (str) – name of a geographic (sub)region (case-insensitive) that is available on BBBike free download server
data_dir (str | None) – directory where the .csv.xz data file is located/saved; if
None
(default), the default directorydownload (bool) – whether to try to download the requisite data file if it does not exist, defaults to
True
verbose (bool | int) – whether to print relevant information in console as the function runs, defaults to
False
- Returns:
tabular data of the .csv.xz file
- Return type:
pandas.DataFrame | None
Examples:
>>> from pydriosm.reader import BBBikeReader >>> from pyhelpers.dirs import cd, delete_dir >>> bbr = BBBikeReader() >>> subrgn_name = 'Leeds' >>> dat_dir = "tests\osm_data" >>> leeds_csv_xz = bbr.read_csv_xz(subrgn_name, dat_dir, verbose=True) The requisite data file "tests\osm_data\leeds\Leeds.osm.csv.xz" does not exist. >>> leeds_csv_xz = bbr.read_csv_xz(subrgn_name, dat_dir, verbose=True, download=True) Downloading "Leeds.osm.csv.xz" to "tests\osm_data\leeds\" ... Done. Parsing the data ... Done. >>> leeds_csv_xz.head() type id feature note 0 node 154915 None None 1 node 154916 None None 2 node 154921 None None 3 node 154922 None None 4 node 154923 None None >>> # Delete the downloaded .csv.xz data file >>> delete_dir(dat_dir, verbose=True) To delete the directory "tests\osm_data\" (Not empty) ? [No]|Yes: yes Deleting "tests\osm_data\" ... Done.