mirror of
https://github.com/tomru/cram-luftdaten.git
synced 2026-03-03 06:27:23 +01:00
fix parsing the date, it is UTC
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
# Converts CSV exports from https://www.madavi.de/sensor/csvfiles.php to
|
||||
# InfluxDB LineProtocol https://docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
|
||||
#
|
||||
# Note: timestamps are in seconds, therefore user precision parameter when
|
||||
# writing, see https://docs.influxdata.com/influxdb/v1.2/tools/api/#write
|
||||
# Note: timestamps are in seconds, therefore precision "s" needs to be set
|
||||
# when writing, see https://docs.influxdata.com/influxdb/v1.2/tools/api/#write
|
||||
|
||||
# CSV file spects
|
||||
# CSV file specs
|
||||
#
|
||||
# | DB Field | DB field | CSV Column | CSV Format
|
||||
# |-------------|----------|-----------------------|---------------------
|
||||
# | time | time | 1 Time | 2017/05/19 00:00:11
|
||||
# |-------------|----------|-----------------------|--------------------------
|
||||
# | time | time | 1 Time | 2017/05/19 00:00:11 (UTC)
|
||||
# | | | 2 durP1 |
|
||||
# | | | 3 ratioP1 |
|
||||
# | | | 4 P1 |
|
||||
@@ -31,9 +31,10 @@
|
||||
# | max_micro | field | 19 Max_cycle | 25198
|
||||
# | | | 20 Signal | -91
|
||||
# | node | tag | -- -- | e.g. esp8266-16229960
|
||||
|
||||
#
|
||||
# TODO:
|
||||
# - check if CSV export is in UTC ?
|
||||
# - using "date" to parse the UTC date for each line is super slow, but
|
||||
# works. There must be something better out there.
|
||||
|
||||
SRC_FILE=${1:-/dev/stdin}
|
||||
|
||||
@@ -44,10 +45,12 @@ NODE=esp8266-$SENSOR_ID
|
||||
|
||||
STRIP_CSV_HEADERS="tail -n +2"
|
||||
|
||||
cat $SRC_FILE \
|
||||
| $STRIP_CSV_HEADERS \
|
||||
| gawk -v db="$DATABASE" -v node="$NODE" \
|
||||
'BEGIN { FS = ";" } ; \
|
||||
{ timestamp=mktime(gensub(/\/|:/," ", "g", $1)); \
|
||||
print db",node="node" SDS_P1="$8",SDS_P2="$9",humidity="$11",min_micro="$18",max_micro="$19",samples="$17",temperature="$10" "timestamp}'
|
||||
cat $SRC_FILE \
|
||||
| $STRIP_CSV_HEADERS \
|
||||
| gawk -v db="$DATABASE" -v node="$NODE" \
|
||||
'BEGIN { FS = ";" } ; \
|
||||
{ convertDate = "date -u --date=\""$1"\" +%s"; \
|
||||
convertDate| getline timestamp; \
|
||||
close(convertDate); \
|
||||
print db",node="node" SDS_P1="$8",SDS_P2="$9",humidity="$11",min_micro="$18",max_micro="$19",samples="$17",temperature="$10" "timestamp }'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user