openaq / openaq-cli

OpenAQ command line interface
MIT License
3 stars 0 forks source link

Add `--wide` flag option for `measurements` #10

Open majesticio opened 1 year ago

majesticio commented 1 year ago

Currently, the output for measurements is displayed in a long format. Introducing a --wide flag can reshape the output data into a wide format. This will make it easier for users to view and compare measurements for different parameters side by side.

Example (shortened for brevity)

"long" format

parameter DATETIME_LOCAL VALUE
no2 ppm 2023-08-29 08:00:00 0.0093
so2 ppm 2023-08-29 08:00:00 0

"wide" format that would use --wide flag

DATETIME_LOCAL no2 ppm value so2 ppm value
2023-08-29 08:00:00 0.0093 0

example use: openaq measurements list 2178 --from 2023-08-29 --wide

russbiggs commented 1 year ago

Something to consider with wide format: Since the column length is variable joining between two outputs can be difficult:

e.g. consider Location A which measures PM2.5 and PM10 and Location B PM2.5, PM10, NO2 and SO2 Location A in wide format may look like:

DATETIME_LOCAL PM2.5 value PM10 value
2023-08-29 08:00:00 0.0093 0

while Location B may look like:

DATETIME_LOCAL NO2 value SO2 value PM2.5 value PM10 value
2023-08-29 08:00:00 1.1 1 0.93 0.0234

If I wanted to join these two CSVs (append one to the other) it would be difficult due to the difference number of columns (also the columns may not be in the same order).

This can be worked around with a static number of columns for wide for format, i.e. ALL parameters supported by OpenAQ, which would make joining two or more locations easier. The downside would obviously be LOTS of columns which LOTS of null values