elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.61k stars 8.22k forks source link

Possibility to strip/sanitize newlines when downloading CSV from searches #168187

Open dcolazin opened 1 year ago

dcolazin commented 1 year ago

Describe the feature: Currently (actually tested on 7.17.6, but behavior is identical on 8.6.2) there is no configuration to possibly strip newline characters from the fields of the generated csv.

The generated csv file is parsed wrongly by the most common spreadsheet editors when used naively: for example, such file is parsed correctly when "loaded" on Excel 2019 (Data -> From Text/CSV), but not when opened (exactly the opposite behavior described on Excel 2007!); I was not able to parse it properly with Libreoffice 7.2 csv text import.

It should be possible to strip newline characters (maybe replacing them with a single space?) to generate csv files that are readily available to be used by less spreadsheet-savvy users and single-line csv editors.

Describe a specific use case for the feature: When downloading a csv from a search, if a field contains newlines it appears as following (assuming the csv delimiter is the pipe | and the quoteValues is on)

"@timestamp"|"field_1"|"field_abc"|"field_potential_newlines_1"|"field_potential_newlines_2"
"Sep 20, 2023 @ 16:02:07.278"|1|"abc"|"{
    ""json_field_2"": ""2"",
    ""json_field_efg"": ""efg""
}"|"MESSAGE=[{
    ""json_field_3"": ""3""
}]"

while it is possible to extract a valid csv from here (ignore newlines between single quotes, "" does not count), it is wrongly parsed by some editors. Related issue #20408

elasticmachine commented 1 year ago

Pinging @elastic/appex-sharedux (Team:SharedUX)