Quantcast
Channel: Latest Questions on Splunk Answers
Viewing all articles
Browse latest Browse all 13053

Field extraction using regex from CSV with optional quotes

$
0
0

I have a .csv file that could look like this:

field 1,field 2,field 3,field 4
value,"value",,"val,ue"
"value","","val,ue",value

As you probably understand, I want to ignore the commas inside the quotes, and I also want to ignore the quotes themselves in the field. So in this case I would have fields containing 'value', 'val,ue' and two empty fields. The problem I'm facing is that the quotes are optional for fields without commas inside of them.

All my regex attempts so far has failed. I've been using the automatic field extractor to extract fields in CSV's without optional quotes, but I can't get it to work with the quotes.

I've been reading through a regex tutorial today, but I still can't manage to write an accurate expression. Solutions, tips or tricks are greatly appreciated!


Viewing all articles
Browse latest Browse all 13053


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>