<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Splunk unable to handle double-quoted CSV? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70773#M14411</link>
    <description>&lt;P&gt;If you &lt;EM&gt;don't&lt;/EM&gt; use the auto header detection (and presumably you stopped using this to try your regex solution) then, as far as I can see, CSV with double quoted fields works fine.&lt;/P&gt;

&lt;P&gt;I've got a setup that has the following in props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
[source::prelertanomaly]
CHARSET = UTF-8
MAX_TIMESTAMP_LOOKAHEAD = 10
TIME_FORMAT = %s
REPORT-prelert = prelertanomaly
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the following in transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
[prelertanomaly]
DELIMS = ","
FIELDS = _time, prelertreferencetime, prelertkey, prelertbucketsize, prelertfieldname, prelertfieldvalue, prelertbaselinerate, prelertcurrentrate, prelertbaselinemean, prelertcurrentmean, sparkline, prelertanomalyfactor, prelertprobability, prelertanomalysearchterms, prelertanomalywhereclause, prelertexamples, prelertmetricfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and it quite happily handles records of this form:&lt;/P&gt;

&lt;P&gt;1362673800,1362673800,unixcpu,300,count,count,3.995050,10,3.995050,10.000000,"##__SPARKLINE__##,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0",0.000000,100.000000,,,,&lt;/P&gt;

&lt;P&gt;Notice that the sparkline there has lots of commas in it inside the surrounding double quotes, and Splunk doesn't break it up.  With my config and the specific event above Splunk extracted these fields:&lt;/P&gt;

&lt;P&gt;host=davids-macbook-pro&lt;BR /&gt;
sourcetype=stash&lt;BR /&gt;
source=prelertanomaly&lt;BR /&gt;
prelertanomalyfactor=0.000000&lt;BR /&gt;
prelertbaselinerate=3.995050&lt;BR /&gt;
prelertbucketsize=300&lt;BR /&gt;
prelertcurrentrate=10&lt;BR /&gt;
prelertfieldname=count&lt;BR /&gt;
prelertfieldvalue=count&lt;BR /&gt;
prelertprobability=100.000000&lt;BR /&gt;
prelertreferencetime=1362673800&lt;BR /&gt;
sparkline=##__SPARKLINE__##,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0&lt;BR /&gt;
time=1362673800&lt;BR /&gt;
prelertkey=unixcpu&lt;BR /&gt;
prelertcurrentmean=10.000000&lt;BR /&gt;
prelertbaselinemean=3.995050&lt;/P&gt;

&lt;P&gt;This works with Splunk 4.3.2 and 5.0.1 at least.&lt;/P&gt;

&lt;P&gt;One annoyance I have seen with the way Splunk parses CSV input data is that it expects double quotes that are to remain part of the field values to be escaped with backslashes, whereas in the CSV that custom search commands take as input and emit as output double quotes are escaped by having two consecutive double quotes (like Excel does it).&lt;/P&gt;</description>
    <pubDate>Thu, 07 Mar 2013 17:20:10 GMT</pubDate>
    <dc:creator>dmr195</dc:creator>
    <dc:date>2013-03-07T17:20:10Z</dc:date>
    <item>
      <title>Splunk unable to handle double-quoted CSV?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70772#M14410</link>
      <description>&lt;P&gt;Example Line:&lt;/P&gt;

&lt;P&gt;"Stuff to be, together as one item",nextvalue,andanother,andso-on&lt;/P&gt;

&lt;P&gt;When using splunk auto header detection and DELIMS="," this blows up and shifts the non-quoted fields back, and gives the values:&lt;/P&gt;

&lt;P&gt;Field1: "Stuff to be&lt;BR /&gt;&lt;BR /&gt;
Field2: together as one item"&lt;BR /&gt;&lt;BR /&gt;
Field3: nextvalue&lt;BR /&gt;&lt;BR /&gt;
Field4: andanother&lt;BR /&gt;&lt;BR /&gt;
Field5: andso-on  &lt;/P&gt;

&lt;P&gt;Any way around this other than a massive regex?  if if you did make a massive regex (we did actually), how would you make it cope with the following:&lt;/P&gt;

&lt;P&gt;LINE1: "Stuff to be, together as one item",nextvalue,andanother,andso-on&lt;/P&gt;

&lt;P&gt;LINE2: "Stuff to be, together as one item, and this stuff too, and there might be 10 of them...",nextvalue,andanother,andso-on&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 22:17:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70772#M14410</guid>
      <dc:creator>vectorsc</dc:creator>
      <dc:date>2012-09-25T22:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk unable to handle double-quoted CSV?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70773#M14411</link>
      <description>&lt;P&gt;If you &lt;EM&gt;don't&lt;/EM&gt; use the auto header detection (and presumably you stopped using this to try your regex solution) then, as far as I can see, CSV with double quoted fields works fine.&lt;/P&gt;

&lt;P&gt;I've got a setup that has the following in props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
[source::prelertanomaly]
CHARSET = UTF-8
MAX_TIMESTAMP_LOOKAHEAD = 10
TIME_FORMAT = %s
REPORT-prelert = prelertanomaly
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the following in transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
[prelertanomaly]
DELIMS = ","
FIELDS = _time, prelertreferencetime, prelertkey, prelertbucketsize, prelertfieldname, prelertfieldvalue, prelertbaselinerate, prelertcurrentrate, prelertbaselinemean, prelertcurrentmean, sparkline, prelertanomalyfactor, prelertprobability, prelertanomalysearchterms, prelertanomalywhereclause, prelertexamples, prelertmetricfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and it quite happily handles records of this form:&lt;/P&gt;

&lt;P&gt;1362673800,1362673800,unixcpu,300,count,count,3.995050,10,3.995050,10.000000,"##__SPARKLINE__##,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0",0.000000,100.000000,,,,&lt;/P&gt;

&lt;P&gt;Notice that the sparkline there has lots of commas in it inside the surrounding double quotes, and Splunk doesn't break it up.  With my config and the specific event above Splunk extracted these fields:&lt;/P&gt;

&lt;P&gt;host=davids-macbook-pro&lt;BR /&gt;
sourcetype=stash&lt;BR /&gt;
source=prelertanomaly&lt;BR /&gt;
prelertanomalyfactor=0.000000&lt;BR /&gt;
prelertbaselinerate=3.995050&lt;BR /&gt;
prelertbucketsize=300&lt;BR /&gt;
prelertcurrentrate=10&lt;BR /&gt;
prelertfieldname=count&lt;BR /&gt;
prelertfieldvalue=count&lt;BR /&gt;
prelertprobability=100.000000&lt;BR /&gt;
prelertreferencetime=1362673800&lt;BR /&gt;
sparkline=##__SPARKLINE__##,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0&lt;BR /&gt;
time=1362673800&lt;BR /&gt;
prelertkey=unixcpu&lt;BR /&gt;
prelertcurrentmean=10.000000&lt;BR /&gt;
prelertbaselinemean=3.995050&lt;/P&gt;

&lt;P&gt;This works with Splunk 4.3.2 and 5.0.1 at least.&lt;/P&gt;

&lt;P&gt;One annoyance I have seen with the way Splunk parses CSV input data is that it expects double quotes that are to remain part of the field values to be escaped with backslashes, whereas in the CSV that custom search commands take as input and emit as output double quotes are escaped by having two consecutive double quotes (like Excel does it).&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2013 17:20:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70773#M14411</guid>
      <dc:creator>dmr195</dc:creator>
      <dc:date>2013-03-07T17:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk unable to handle double-quoted CSV?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70774#M14412</link>
      <description>&lt;P&gt;oddly, the inputs and such we were using and the methods we used were identical to the way you were doing it.  It still didn't work in 4.3.2.  &lt;/P&gt;

&lt;P&gt;That said, we were able to change the double quoted commas to something else (pipe symbol) and that worked just fine.  Most aggravating.  I will likely re-attempt this issue at a later date in 5.x&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2013 17:35:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-unable-to-handle-double-quoted-CSV/m-p/70774#M14412</guid>
      <dc:creator>vectorsc</dc:creator>
      <dc:date>2013-03-07T17:35:41Z</dc:date>
    </item>
  </channel>
</rss>

