parsing fields from csv with delimeter in the data
I have CSV logs I'm bringing in that can sometimes have a comma in the value, and IF a comma exists then the value will be surrounded in quotes, otherwise it will not be quoted. for example the CSV data below:
date,type,name,description
05052021,"001,003",Joe Smith,"description, with a comma"
05052021,002,"Jones,Bill",description without a comma
05052021,003,"Smith,Emmitt","again, with comma"
I'm assuming this will be done with regex, but I'm nto sure how to go about it. Thanks in asvance!
-
The CSV operator should actually take care of this for you and should handle those quoted fields.
| csv _raw extract a, b, c, d
Using the following format you can also extract specific fields by their position.| csv _raw extract 3 as name, 4 as description
Please sign in to leave a comment.
Comments
2 comments