Bugazelle / export-csv-to-influx

The python library to write the CSV data into Influx. Support me via Bitcoin: bc1qqgkmph9cvygzxfpupv4jr4n0nfx3qumwg39j5w
BSD 3-Clause "New" or "Revised" License
32 stars 11 forks source link

Time zone format #18

Closed dwkisker closed 4 years ago

dwkisker commented 5 years ago

Very simple question. what is the format for entering a parameter for the time_zone variable? My data is no taken in the UTC zone, but rather UTC-7

I have tried a few options, UTC-7, GMT-7, MDT (Mountain Daylight Time in US) but none are recognized. What is the proper format please? By the way, so far, your program is working very well for me.

dwkisker commented 5 years ago

I found the answer--the format is that which is used in the "pytz" function. These can be found here: https://stackoverflow.com/questions/36067621/python-all-possible-timezone-abbreviations-for-given-timezone-name-and-vise-ve In my case, it was "America/Denver" (Note that as usual, this does not take the issue of daylight savings time into account.)

Bugazelle commented 4 years ago

Sorry for the delay. I am focusing on it now. And will response you ASAP.

Bugazelle commented 4 years ago

Hello @dwkisker,

Would you please try use the "-tz" to change your timezone?

-tz, --time_zone, Timezone of supplied data. Default: UTC.

Just now, I tried your timezone "America/Denver" at my side. It is working on my side. And thank you for clarify the "pytz" function. Here is the logs:

1. Run exporter

export_csv_to_influx \
    --csv demo.csv \
    --dbname demo \
    --measurement denver \
    --tag_columns url \
    --field_columns response_time \
    --user admin \
    --password admin \
    --force_insert_even_csv_no_update True \
    --server 127.0.0.1:8086 \
    --time_zone "America/Denver"

2. The csv the 1st line of demo.csv is:

2019-07-11 02:04:05,https://jmeter.apache.org/,1.434

3. the result

> use demo
Using database demo
> select * from denver limit 1
name: denver
time                response_time url
----                ------------- ---
1562832245000000000 1.434         https://jmeter.apache.org/

4. Verify result The converted timestamp "1562832245" is matched to "America/Denver" - 2019-07-11 02:04:05. https://www.epochconverter.com/timezones?q=1562832245&tz=America%2FDenver

dwkisker commented 4 years ago

Yes. This now works. The primary issue was needing the exact format for the timezone.

I have a lot to learn about python, but your work has greatly simplified this part of it...