telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

CSV parsing issue

Open miurlit opened this issue 4 years ago • 11 comments

Since version 1.21 there seems to be an issue with CSV files, I am getting a parsing error:

Jan 3 02:14:20 raspberrypi telegraf[426]: 2022-01-03T01:14:20Z E! [inputs.file] Error in plugin: parsing time "dd/MM/yyyy HH:mm:ss z" as "02/01/2006 15:04:05 -0700": cannot parse "dd/MM/yyyy HH:mm:ss z" as "02"

If revert back to 1.20.4 no error occurs with the same CSV file.

Thanks

miurlit avatar Jan 03 '22 11:01 miurlit

I have the same problem. Going down the version to 1.20.4 also fixed it. Here is the config for the input I use:

[[inputs.file]]

files = ["/path/to/file.csv"]
name_override = "custom"
data_format = "csv"
csv_header_row_count = 1
csv_delimiter = ";"
csv_timestamp_column = "dd/MM/yyyy HH:mm:ss"
csv_timestamp_format = "02/01/2006 15:04:05"
csv_timezone = "Europe/Berlin"

jonilala796 avatar Jan 08 '22 14:01 jonilala796

I have the same problem with version 1.21.2. Fixed by downgrading to 1.20.4.

Logs: E! [inputs.http::alias] Error in plugin: [url=http://]: strconv.ParseInt: parsing "TimeInt": invalid syntax

Config:

[[inputs.http]]
  urls = ["http://"]
  data_format = "csv"
  csv_delimiter = ";"
  csv_header_row_count = 1
  csv_tag_columns = [""]
  csv_timestamp_column = "TimeInt"
  csv_timestamp_format = "unix"

gwlqt avatar Jan 19 '22 15:01 gwlqt

Can you provide a CSV file your trying to parse so we can reproduce this issue? There were changes made to the parser from v1.20->v1.21, but it isn't obvious what is causing this issue at first glance.

sspaink avatar Jan 19 '22 20:01 sspaink

Here is a CSV file: example.csv. Thanks for looking into this!

gwlqt avatar Jan 20 '22 08:01 gwlqt

I think I found the problem in this PR: https://github.com/influxdata/telegraf/pull/10484, it only happens when you run Gather twice the second time the code accidentally changed the configured csv_header_row_count so it would try to parse the header as data. There is still some issue with some of the test expecting the configured value to change that I need to work through.

sspaink avatar Jan 20 '22 22:01 sspaink

Sorry, but it seems the issue still persists in 1.21.3?! I still geht the same error as in my original post...

miurlit avatar Jan 30 '22 10:01 miurlit

Yeah the PR was closed without any actions taken. Here is the sample data from me: https://pastebin.com/VD4r5U8x

jonilala796 avatar Jan 30 '22 10:01 jonilala796

@miurlit @jonilala796,

Thanks, we know it is still an open issue. The PR discovered it will require a different approach to fix so it was closed.

powersj avatar Jan 30 '22 17:01 powersj

@miurlit @jonilala796,

Thanks, we know it is still an open issue. The PR discovered it will require a different approach to fix so it was closed.

Ok, thanks for clarifying.

miurlit avatar Jan 30 '22 18:01 miurlit

Hey @miurlit, @jonilala796 @gwlqt, I cooked up an approach in #10575 and would be happy to get feedback if that solves your issues!?!? Could you please add a comment to the PR on your results? Thanks!

srebhan avatar Feb 03 '22 08:02 srebhan

@srebhan sorry, was not actively following this conversation, but I am afraid that the issue still persists with the latest release (1.21.4)

miurlit avatar Feb 26 '22 15:02 miurlit