Emission Import
This section outlines instructions on how to import data into the platform using helper scripts and the input format for the data.
GitHub Repository
Location of the scripts: github.com/aerscape/data-pipelines
Getting Started
Clone the repository
git clone git@github.com:/aerscape/data-pipelinesInstall dependencies
Install the requests library via pip:
pip install requestsGetting the latest code
Before running, make sure to have the latest code and cd into the dataimport-scripts folder:
git pull
cd dataimport-scriptsQuick Reference
Before running any script:
cd {PROJECTS_ROOT}/data-pipelines/
git pull
cd dataimport-scriptsCommon command examples:
# Emissions Bridger
python -m importers.emissions.bridger --environment dev --api_key {API_KEY_VALUE} --data_path {PATH_TO_FOLDER} --data_source SELF_REPORTED
# Emissions Generic (Any data provider)
python -m importers.emissions.generic --environment staging --api_key {API_KEY_VALUE} --data_path {PATH_TO_FOLDER} --data_provider "Existing Data Provider" --contains_no_detects 1 --data_source SELF_REPORTED
# Aerial Images
python -m importers.infrastructure.aerial_images --environment prod --api_key {API_KEY_VALUE} --data_path {PATH_TO_FOLDER}
# Pipelines
python -m importers.infrastructure.pipelines --environment prod --api_key {API_KEY_VALUE} --data_path {PATH_TO_FOLDER} --owner {OWNER_NAME}Available Import Scripts
Emission Imports
- Bridger - Bridger data and nondetects
- Planet Tanager-1 - Planet emissions and scenes
- GHGSat - GHGSat data
- EPA - EPA SEP NOTIFIED and SCRAPED data
- Generic - Generic importer for any data provider
- EDF MethaneAir - EDF MethaneAir data with CSV transformation
Infrastructure Imports
- Infrastructure - Aerial images, pipelines, and infrastructure data
Common Script Arguments
The following arguments are required for each script:
--environment- Environment to import to:local,dev,prod-testing, orprod--api_key- Retrieved from the platform data_import admin view--data_path- Full path to the folder containing data import files
Preparing the Data
Each script expects a path to a folder containing a data package. The package must contain:
- Exactly one CSV file formatted to the script specification. If there is no CSV file found or if there are multiple CSV files found, the script will fail.
- Referenced files: If a TIFF image or other file is referenced in the CSV file, it must be present in the data package, otherwise the script will fail.
Important: CSV files cannot have byte order mark (Excel adds by default). Use :set nobomb in vim to remove.
Error Handling
The import process follows an all-or-nothing rule - it'll try to process the operations sequentially, and if anything fails, it rolls back the entire process.
The messages are all being stored in the database. For common errors and solutions, see the Troubleshooting guide.