<?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 lookup using csv-keys as input and csv-values as output in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359720#M106367</link>
    <description>&lt;P&gt;Try this... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field1="a" | eval field2="b" | eval  field3=",1,2,3," | eval field4="c" | eval field5="d"
| rename COMMENT as "The above enters your test data"

| rename COMMENT as "Deal with the leading comma, mark spots to split the data, split the data into separate records"
| rex mode=sed field=field3 "s/^,/((nothing)),/g s/,/,!!!!/g s/!!!!$//g"
| makemv delim="!!!!" field3
| mvexpand field3

| rename COMMENT as "Do the lookup, add a comma if found"
| lookup mylookup.csv field3 OUTPUT field3b
| eval field3=if(isnull(field3b),field3,field3b.",")
| fields - field3b
| rename COMMENT as "For run anywhere you can just delete the lookup to prove it works"

| rename COMMENT as "Recombine the records, join them, undo the fix for the leading comma, voila"
| mvcombine field3
| eval field3=mvjoin(field3,"!!!!")
| rex mode=sed field=field3 "s/\(\(nothing\)\),/,/g s/,!!!!/,/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Sep 2017 18:08:41 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-09-27T18:08:41Z</dc:date>
    <item>
      <title>Splunk lookup using csv-keys as input and csv-values as output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359719#M106366</link>
      <description>&lt;P&gt;I have event data as follows: &lt;CODE&gt;a,b,",1,2,3,",c,d&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;And I have lookup table as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key,     value
1,       one
2,       two
3,       three
4,       four
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need the following output using lookup&lt;BR /&gt;
a,b,",one,two,three,",c,d&lt;/P&gt;

&lt;P&gt;note ",1,2,3," is not fixed in size.&lt;/P&gt;

&lt;P&gt;Any help appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 23:42:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359719#M106366</guid>
      <dc:creator>bhupalbobbadi</dc:creator>
      <dc:date>2017-09-26T23:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk lookup using csv-keys as input and csv-values as output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359720#M106367</link>
      <description>&lt;P&gt;Try this... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field1="a" | eval field2="b" | eval  field3=",1,2,3," | eval field4="c" | eval field5="d"
| rename COMMENT as "The above enters your test data"

| rename COMMENT as "Deal with the leading comma, mark spots to split the data, split the data into separate records"
| rex mode=sed field=field3 "s/^,/((nothing)),/g s/,/,!!!!/g s/!!!!$//g"
| makemv delim="!!!!" field3
| mvexpand field3

| rename COMMENT as "Do the lookup, add a comma if found"
| lookup mylookup.csv field3 OUTPUT field3b
| eval field3=if(isnull(field3b),field3,field3b.",")
| fields - field3b
| rename COMMENT as "For run anywhere you can just delete the lookup to prove it works"

| rename COMMENT as "Recombine the records, join them, undo the fix for the leading comma, voila"
| mvcombine field3
| eval field3=mvjoin(field3,"!!!!")
| rex mode=sed field=field3 "s/\(\(nothing\)\),/,/g s/,!!!!/,/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2017 18:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359720#M106367</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-27T18:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk lookup using csv-keys as input and csv-values as output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359721#M106368</link>
      <description>&lt;P&gt;Thanks tons. It worked as I wanted.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 20:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-lookup-using-csv-keys-as-input-and-csv-values-as-output/m-p/359721#M106368</guid>
      <dc:creator>bhupalbobbadi</dc:creator>
      <dc:date>2017-09-27T20:47:13Z</dc:date>
    </item>
  </channel>
</rss>

