### Get list of available tables Source: https://github.com/j535d165/cbsodata/blob/main/README.md Retrieve a list of all available data tables from the Statistics Netherlands open data portal. The first element of the returned list is printed as an example. ```python >>> tables = cbsodata.get_table_list() >>> print(tables[0]) ``` -------------------------------- ### Install cbsodata package Source: https://github.com/j535d165/cbsodata/blob/main/README.md Install the cbsodata package using pip. This command is used to add the library to your Python environment. ```sh pip install cbsodata ``` -------------------------------- ### Import cbsodata package Source: https://github.com/j535d165/cbsodata/blob/main/README.md Import the cbsodata library into your Python script to start using its functionalities. ```python import cbsodata ``` -------------------------------- ### Get Data from CBS Open Data Source: https://github.com/j535d165/cbsodata/blob/main/README.md Fetches data for a given dataset ID. The result is a list of dictionaries representing the table data. ```python >>> data = cbsodata.get_data('82070ENG') [{'CaribbeanNetherlands': 'Bonaire', 'EmployedLabourForceInternatDef_1': 8837, 'EmployedLabourForceNationalDef_2': 8559, 'Gender': 'Total male and female', 'ID': 0, 'Periods': '2012', 'PersonalCharacteristics': 'Total personal characteristics'}, {'CaribbeanNetherlands': 'St. Eustatius', 'EmployedLabourForceInternatDef_1': 2099, 'EmployedLabourForceNationalDef_2': 1940, 'Gender': 'Total male and female', 'ID': 1, 'Periods': '2012', 'PersonalCharacteristics': 'Total personal characteristics'}, {'CaribbeanNetherlands': 'Saba', 'EmployedLabourForceInternatDef_1': 1045, 'EmployedLabourForceNationalDef_2': 971, 'Gender': 'Total male and female', 'ID': 2, 'Periods': '2012', 'PersonalCharacteristics': 'Total personal characteristics'}, # ... ] ``` -------------------------------- ### Get information about a specific table Source: https://github.com/j535d165/cbsodata/blob/main/README.md Fetch detailed information about a specific data table using its identifier. The 'Title' and 'Modified' fields of the returned dictionary are displayed. ```python >>> info = cbsodata.get_info('82070ENG') # Returns a dict with info >>> info['Title'] 'Caribbean Netherlands; employed labour force characteristics 2012' >>> info['Modified'] '2013-11-28T15:00:00' ``` -------------------------------- ### CLI Help Source: https://github.com/j535d165/cbsodata/blob/main/README.md Displays the help message for the cbsodata command-line interface, showing available subcommands and options. ```bash > cbsodata -h usage: cbsodata [-h] [--version] [subcommand] CBS Open Data: Command Line Interface positional arguments: subcommand the subcommand (one of 'data', 'info', 'list') optional arguments: -h, --help show this help message and exit --version show the package version ``` -------------------------------- ### CLI List All Tables Source: https://github.com/j535d165/cbsodata/blob/main/README.md Retrieves and displays a list of all available tables using the command-line interface. ```bash > cbsodata list ``` -------------------------------- ### Access Data from Alternative Catalogs (Context Manager) Source: https://github.com/j535d165/cbsodata/blob/main/README.md Uses a context manager to temporarily set an alternative catalog URL for retrieving a table list and a specific dataset. ```python with cbsodata.catalog('dataderden.cbs.nl'): # list tables cbsodata.get_table_list() # get dataset 47003NED cbsodata.get_data('47003NED') ``` -------------------------------- ### Download Data Directly to File Source: https://github.com/j535d165/cbsodata/blob/main/README.md Fetches data and saves it directly to the specified directory on the file system using the 'dir' argument. ```python >>> data = cbsodata.get_data('82070ENG', dir="dir_to_save_data") ``` -------------------------------- ### Access Data from Alternative Catalogs (Module Level) Source: https://github.com/j535d165/cbsodata/blob/main/README.md Configures the library to use an alternative catalog URL at the module level and then retrieves a table list and specific dataset. ```python cbsodata.options.catalog_url = 'dataderden.cbs.nl' # list tables cbsodata.get_table_list() # get dataset 47003NED cbsodata.get_data('47003NED') ``` -------------------------------- ### CLI Retrieve Table Information Source: https://github.com/j535d165/cbsodata/blob/main/README.md Retrieves and displays information about a specified table ID using the command-line interface. ```bash > cbsodata info 82010NED ``` -------------------------------- ### CLI Export Data to JSON Lines Source: https://github.com/j535d165/cbsodata/blob/main/README.md Downloads data for a specified table ID and exports it to a JSON Lines file using the '-o' flag. ```bash > cbsodata data 82010NED -o table_82010NED.jl ``` -------------------------------- ### CLI Download Data Source: https://github.com/j535d165/cbsodata/blob/main/README.md Downloads data for a specified table ID using the command-line interface. ```bash > cbsodata data 82010NED ``` -------------------------------- ### Access Data from Alternative Catalogs (Function Argument) Source: https://github.com/j535d165/cbsodata/blob/main/README.md Specifies an alternative catalog URL directly as a function argument when retrieving a table list and a specific dataset. ```python # list tables cbsodata.get_table_list(catalog_url='dataderden.cbs.nl') # get dataset 47003NED cbsodata.get_data('47003NED', catalog_url='dataderden.cbs.nl') ``` -------------------------------- ### cbsodata.get_table_list Source: https://github.com/j535d165/cbsodata/blob/main/docs/reference.md Fetches a list of all available tables in the CBS catalog. You can optionally filter or select specific columns. ```APIDOC ## cbsodata.get_table_list ### Description Get a list with the available tables. ### Parameters #### Path Parameters * **select** (list or str) - Optional - Column label or list of column labels to return. * **filters** (str) - Optional - Return only rows that agree on the filter. * **catalog_url** (str) - Optional - The url of the catalog. Default “opendata.cbs.nl”. * **kwargs** - Optional - Optional arguments that `requests.get()` takes. For example, proxies, cert and verify. ### Method N/A (Function) ### Endpoint N/A (Function) ### Request Example N/A (Function) ### Response #### Success Response * **Return type**: list - A list with the description of each table in the catalog. ``` -------------------------------- ### cbsodata.get_info Source: https://github.com/j535d165/cbsodata/blob/main/docs/reference.md Fetches general information about a specific CBS data table. You need to provide the table ID and optionally the catalog URL. ```APIDOC ## cbsodata.get_info ### Description Get information about a table. ### Parameters #### Path Parameters * **table_id** (str) - Required - The identifier of the table. * **catalog_url** (str) - Optional - The url of the catalog. Default “opendata.cbs.nl”. * **kwargs** - Optional - Optional arguments that `requests.get()` takes. For example, proxies, cert and verify. ### Method N/A (Function) ### Endpoint N/A (Function) ### Request Example N/A (Function) ### Response #### Success Response * **Return type**: dict - Table information ``` -------------------------------- ### cbsodata.download_data Source: https://github.com/j535d165/cbsodata/blob/main/docs/reference.md Downloads CBS data and associated metadata. You can specify the table ID, download directory, data selection, filters, and catalog URL. ```APIDOC ## cbsodata.download_data ### Description Download the CBS data and metadata. ### Parameters #### Path Parameters * **table_id** (str) - Required - The identifier of the table. * **dir** (str) - Optional - Folder to save data to. If not given, data is not stored on disk. * **typed** (bool) - Optional - Return a typed data table. Default False. * **select** (str or list) - Optional - Column label or list of column labels to return. * **filters** (str) - Optional - Return only rows that agree on the filter. * **catalog_url** (str) - Optional - The url of the catalog. Default “opendata.cbs.nl”. * **kwargs** - Optional - Optional arguments that `requests.get()` takes. For example, proxies, cert and verify. ### Method N/A (Function) ### Endpoint N/A (Function) ### Request Example N/A (Function) ### Response #### Success Response * **Return type**: list - A dictionary with the (meta)data of the table ``` -------------------------------- ### cbsodata.catalog Source: https://github.com/j535d165/cbsodata/blob/main/docs/reference.md Provides a context manager for interacting with CBS data catalogs. It allows you to specify the catalog URL and whether to use HTTPS. ```APIDOC ## cbsodata.catalog ### Description Context manager for catalogs. ### Parameters #### Path Parameters * **catalog_url** (str) - Required - Url for the catalog. For example: dataderden.cbs.nl. * **use_https** (bool) - Optional - Use https. Default True. ### Method N/A (Context Manager) ### Endpoint N/A (Context Manager) ### Request Example N/A (Context Manager) ### Response N/A (Context Manager) ``` -------------------------------- ### cbsodata.get_meta Source: https://github.com/j535d165/cbsodata/blob/main/docs/reference.md Retrieves specific metadata for a CBS data table. Requires the table ID and the name of the metadata to fetch (e.g., DataProperties). ```APIDOC ## cbsodata.get_meta ### Description Get the metadata of a table. ### Parameters #### Path Parameters * **table_id** (str) - Required - The identifier of the table. * **name** (str) - Required - The name of the metadata (for example DataProperties). * **catalog_url** (str) - Optional - The url of the catalog. Default “opendata.cbs.nl”. * **kwargs** - Optional - Optional arguments that `requests.get()` takes. For example, proxies, cert and verify. ### Method N/A (Function) ### Endpoint N/A (Function) ### Request Example N/A (Function) ### Response #### Success Response * **Return type**: list - A list with metadata (dict type) ``` -------------------------------- ### cbsodata.get_data Source: https://github.com/j535d165/cbsodata/blob/main/docs/reference.md Retrieves CBS data tables. This function allows you to fetch data by table ID, specify download options, select columns, apply filters, and choose the catalog URL. ```APIDOC ## cbsodata.get_data ### Description Get the CBS data table. ### Parameters #### Path Parameters * **table_id** (str) - Required - The identifier of the table. * **dir** (str) - Optional - Folder to save data to. If not given, data is not stored on disk. * **typed** (bool) - Optional - Return a typed data table. Default False. * **select** (list) - Optional - Column label or list of column labels to return. * **filters** (str) - Optional - Return only rows that agree on the filter. * **catalog_url** (str) - Optional - The url of the catalog. Default “opendata.cbs.nl”. * **kwargs** - Optional - Optional arguments that `requests.get()` takes. For example, proxies, cert and verify. ### Method N/A (Function) ### Endpoint N/A (Function) ### Request Example N/A (Function) ### Response #### Success Response * **Return type**: list - The requested data. ``` -------------------------------- ### Convert Table List to Pandas DataFrame Source: https://github.com/j535d165/cbsodata/blob/main/README.md Converts the list of available tables into a pandas DataFrame. ```python >>> tables = pandas.DataFrame(cbsodata.get_table_list()) >>> tables.head() ``` -------------------------------- ### Convert Data to Pandas DataFrame Source: https://github.com/j535d165/cbsodata/blob/main/README.md Converts the retrieved data (list of dictionaries) into a pandas DataFrame for easier data manipulation and analysis. ```python >>> data = pandas.DataFrame(cbsodata.get_data('82070ENG')) >>> data.head() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.