<?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: Extract with PairDelim KeyDelim in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497458#M194804</link>
    <description>&lt;P&gt;Thanks and that works but adds a lot of zero values making it difficult to chart. If I treat each line like a separate event I should be able to pull out each dataCode and Value and only show events where the data is present if that makes sense.  &lt;/P&gt;</description>
    <pubDate>Fri, 15 May 2020 13:02:42 GMT</pubDate>
    <dc:creator>aliquori</dc:creator>
    <dc:date>2020-05-15T13:02:42Z</dc:date>
    <item>
      <title>Extract with PairDelim KeyDelim</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497454#M194800</link>
      <description>&lt;P&gt;I have the following data in csv format:&lt;/P&gt;

&lt;P&gt;date,year,quarter,statementType,dataCode,value&lt;BR /&gt;
2020-03-31,2020,1,balanceSheet,ppeq,1047418000.0&lt;BR /&gt;
2020-03-31,2020,1,balanceSheet,acctRec,0.0&lt;BR /&gt;
2020-03-31,2020,1,incomeStatement,ebt,-20269000.0&lt;BR /&gt;
2020-03-31,2020,1,incomeStatement,consolidatedIncome,-14061000.0&lt;BR /&gt;
2020-03-31,2020,1,overview,bvps,12.4058406156063&lt;/P&gt;

&lt;P&gt;I am trying to parse these so that dataCode values are the field names and Values remain the values. &lt;/P&gt;

&lt;P&gt;Using INDEXED_EXTRACTIONS =csv in my props.conf results in ppeq, acctRec being dataCode values and the same for their actual values. &lt;/P&gt;

&lt;P&gt;I have tried using | extract pairdelim="," kvdelim="," which associates correctly but also adds the date ex. &lt;BR /&gt;
acctRec : 0.0 2020-03-31&lt;/P&gt;

&lt;P&gt;I also looked at adding a transforms to parse out the fields using this \d+,\d+,\w+,\w+,(\w+)\,(\S+) but it does not appear that fields can be dynamically assigned and would all have to be specified. Any advice is greatly appreciated. &lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 22:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497454#M194800</guid>
      <dc:creator>aliquori</dc:creator>
      <dc:date>2020-05-14T22:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract with PairDelim KeyDelim</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497455#M194801</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I assume you want the result to look somewhat like this:&lt;BR /&gt;
date, year, quarter, statementType,ppeq,acctRec,ebt,consolidatedIncome,bvps&lt;BR /&gt;
2020-03-31,2020,1,balanceSheet,1047418000.0, 0.0, 0.0, 0.0, 0.0&lt;BR /&gt;
2020-03-31,2020,1,IncomeStatement, 0.0, 0.0, -20269000.0, -14061000.0, 0.0&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;The trick is to use an eval to create the "new" fields:&lt;BR /&gt;
&lt;CODE&gt;| eval ppeq=if(dataCode="ppeq",value,0.0), acctRec=if(dataCode="acctRec",value,0.0), ebt=if(dataCode="ebt",value,0.0)&lt;/CODE&gt; ... &lt;/P&gt;

&lt;P&gt;Hope it helps&lt;BR /&gt;
Oliver&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 09:22:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497455#M194801</guid>
      <dc:creator>ololdach</dc:creator>
      <dc:date>2020-05-15T09:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract with PairDelim KeyDelim</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497456#M194802</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Check this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...yourquery..| table date,year,quarter,statementType,dataCode,value 
| eval {dataCode}=value 
| fillnull value=0.0 
| fields - dataCode,value
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 May 2020 09:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497456#M194802</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2020-05-15T09:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract with PairDelim KeyDelim</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497457#M194803</link>
      <description>&lt;P&gt;Thanks Oliver, &lt;/P&gt;

&lt;P&gt;That definitely works on a small scale, is there any way to have splunk dynamically create the fields at index or search time? I have over 100 fields with new ones potentially coming in every day. &lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 12:50:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497457#M194803</guid>
      <dc:creator>aliquori</dc:creator>
      <dc:date>2020-05-15T12:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract with PairDelim KeyDelim</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497458#M194804</link>
      <description>&lt;P&gt;Thanks and that works but adds a lot of zero values making it difficult to chart. If I treat each line like a separate event I should be able to pull out each dataCode and Value and only show events where the data is present if that makes sense.  &lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 13:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497458#M194804</guid>
      <dc:creator>aliquori</dc:creator>
      <dc:date>2020-05-15T13:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract with PairDelim KeyDelim</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497459#M194805</link>
      <description>&lt;P&gt;I found an alternative solution by extracting at index time: &lt;/P&gt;

&lt;P&gt;Transforms.conf &lt;BR /&gt;
[csv_pair]&lt;BR /&gt;
REGEX = -\d+\,\d+\,\d+\,\w+\,(\w+)\,(\S+)&lt;BR /&gt;
FORMAT = $1::$2&lt;BR /&gt;
REPEAT_MATCH = true&lt;BR /&gt;
WRITE_META = true&lt;/P&gt;

&lt;P&gt;props.conf&lt;BR /&gt;
[csv]&lt;BR /&gt;
TRANSFORMS-csv = csv_pair&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:27:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-with-PairDelim-KeyDelim/m-p/497459#M194805</guid>
      <dc:creator>aliquori</dc:creator>
      <dc:date>2020-09-30T05:27:33Z</dc:date>
    </item>
  </channel>
</rss>

