lune-shipping-csv-tool
v3.0.4
Published
lune-shipping-csv-tool ======================
Downloads
6
Keywords
Readme
lune-shipping-csv-tool
Repository: https://github.com/lune-climate/lune-shipping-csv-tool
Intro
This is a simple utility that will help to estimate CO2 emissions (caused by shipping goods for example) of multi-leg shipments. This is done via using the Lune API.
Installing from NPM (AKA "I just want to use the application")
This is supported on Unix-like (Linux, BSD, macOS etc.) and Windows.
- Install Node if you don't have it already: https://nodejs.org/en/
- Install lune-shipping-csv-tool globally via running command
npm install -g lune-shipping-csv-tool
in a command-line interpreter (typically Terminal on OSX or Command Prompt on Windows).- If you get a
EACCES: permission denied
error, there are multiple ways to solve the issue, pick one:- follow instructions here.
- prefix the above command with
sudo
, to run the above command as Super User.
- If you get a
- If the installation was successfully you should be able to run
lune-shipping-csv-tool
in the command-line interpreter although this will result in an errorPlease set the LUNE_API_KEY environment variable
Now follow the How to use instructions.
Run npm update -g lune-shipping-csv-tool
to update the tool to the latest version (note
that new versions may introduce some backwards-incompatible changes).
Running the development version (AKA "I want to see how it works or make some changes")
This requires a Unix-like operating system (Linux, BSD, macOS, Windows with WSL etc.).
- Clone this repository (https://github.com/lune-climate/lune-shipping-csv-tool)
- Install Node if you don't have it already
- Install a package manager if you don't have it already
- Install all dependencies via
npm install
oryarn
depending on your package manager of choice - Run the utility via
npm run start
oryarn start
depending on your package manager of choice
Now follow the How to use instructions. Remember to mentally replace all
lune-shipping-csv-tool
occurrences with yarn start
(or npm run start
, if you use npm
) – you
are running the development version after all.
Run git
commands to update the local clone of the repository with the latest upstream changes
(note that some of them may be backwards-incompatible).
How to use
This utility is a CLI application that parses a CSV file, makes a request to the Lune API for each row, and outputs a new CSV file with the estimated CO2 emissions.
You will need a valid Lune API key (you can generate one from https://dashboard.lune.co/developers) - it doesn't matter if
it's a live/test key. The application expects the API key to be provided to it via an LUNE_API_KEY
environment variable:
# Unix-like
export LUNE_API_KEY=<the API key secret goes here>
# Windows
set LUNE_API_KEY=<The API key secret goes here>
You will also need to create a CSV input file. Please examine this existing file to understand the format. We have documented The CSV Input format.
Then to actually run the tool:
lune-shipping-csv-tool <path to the input CSV file>
The output file will appear in the current directory. If you want to define the output directory:
lune-shipping-csv-tool <path to the input CSV file> -o <path to the output directory>
The CSV Input format
Each row in the CSV file represents a multi-leg journey. The following columns are always present:
shipment_id
-> a unique identifier for the shipmentestimate_id
-> a unique identifier for the estimate: populated by the tool after runningtotal_mass_tco2
-> the total estimated CO2 emissions for the shipment: populated by the tool after runningtotal_distance_km
-> the total distance of the shipment in km: populated by the tool after runningerror
-> any error that occurred while processing the shipment: populated by the tool after runningmass_kg
/containers
-> only provide one of these two columns.mass_kd
represents the total mass of the shipment in kg. whilecontainers
represents the number of containers in the shipment.pickup_country
-> start point of the journeypickup_city
-> start city of the journeypickup_postcode
-> postcode of the start citypickup_street
-> street of the start of the journeypickup_coordinates
-> the geopgrahic coordinates of the pickup location
Additionally, you need to provide at least a single leg of the journey. The following columns are required for each leg:
leg1_method
-> the method of transport for the leg. Optional ifleg1_imo_number
is provided.leg1_country
-> the country codeleg1_city
-> the cityleg1_postcode
-> the postcodeleg1_street
-> the streetleg1_coordinates
-> the geographic coordinates of the locationleg1_distance_km
-> optional. If provided, the tool will use this value instead of calculating it. Thus you can skip the address info.leg1_imo_number
-> optional. If provided, the method of transportation will be calculated as IdentifiedVesselShippingMethod.
The _coordinates
fields are mutually exclusive with (_country
, _city
, _postcode
,
_street
) – you can provide only one or the other.
Documentation: https://docs.lune.co/resources/emission-estimates/create-multi-leg-shipping-estimate
Additionally, the following columns should be present but left empty:
leg1_estimated_distance_km
-> the estimated distance of the leg in km. Populated by the tool after runningleg1_total_tco2_
-> the estimated CO2 emissions of the leg in kg. Populated by the tool after running
You can provide up to 10 legs in this way. Checkout the sample input to get a better idea.