<?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 How to write lookup csv file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-lookup-csv-file/m-p/326095#M97224</link>
    <description>&lt;P&gt;Hi Splunk Experts,&lt;/P&gt;

&lt;P&gt;I am preparing one POC , here what I want .&lt;/P&gt;

&lt;P&gt;I have data in splunk like (empId,name,deparment) . I have prepared csv lookup and csv has (empid , salary) columns . What I want is to write back the csv file and add only those employees which does not exist and ignore if empid exists.  For example &lt;/P&gt;

&lt;P&gt;Splunk Data is &lt;BR /&gt;
empId,name,deparment,salary&lt;BR /&gt;
1,vg,finance,10$&lt;BR /&gt;
2,gv,it,20$&lt;BR /&gt;
3,abc,IT,30$&lt;/P&gt;

&lt;P&gt;lookup file&lt;BR /&gt;
empId,Salary&lt;BR /&gt;
1,10$&lt;BR /&gt;
2,20$&lt;/P&gt;

&lt;P&gt;Now I want to update csv using outputlookup command , but only for empid 3 . Please suggest how I can achieve this .&lt;/P&gt;

&lt;P&gt;So my outputlookup csv should look like &lt;BR /&gt;
empId,Salary&lt;BR /&gt;
1,10$&lt;BR /&gt;
2,20$&lt;BR /&gt;
3,30$&lt;/P&gt;

&lt;P&gt;Reagrds&lt;BR /&gt;
VG&lt;/P&gt;</description>
    <pubDate>Thu, 01 Mar 2018 15:26:47 GMT</pubDate>
    <dc:creator>vikas_gopal</dc:creator>
    <dc:date>2018-03-01T15:26:47Z</dc:date>
    <item>
      <title>How to write lookup csv file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-lookup-csv-file/m-p/326095#M97224</link>
      <description>&lt;P&gt;Hi Splunk Experts,&lt;/P&gt;

&lt;P&gt;I am preparing one POC , here what I want .&lt;/P&gt;

&lt;P&gt;I have data in splunk like (empId,name,deparment) . I have prepared csv lookup and csv has (empid , salary) columns . What I want is to write back the csv file and add only those employees which does not exist and ignore if empid exists.  For example &lt;/P&gt;

&lt;P&gt;Splunk Data is &lt;BR /&gt;
empId,name,deparment,salary&lt;BR /&gt;
1,vg,finance,10$&lt;BR /&gt;
2,gv,it,20$&lt;BR /&gt;
3,abc,IT,30$&lt;/P&gt;

&lt;P&gt;lookup file&lt;BR /&gt;
empId,Salary&lt;BR /&gt;
1,10$&lt;BR /&gt;
2,20$&lt;/P&gt;

&lt;P&gt;Now I want to update csv using outputlookup command , but only for empid 3 . Please suggest how I can achieve this .&lt;/P&gt;

&lt;P&gt;So my outputlookup csv should look like &lt;BR /&gt;
empId,Salary&lt;BR /&gt;
1,10$&lt;BR /&gt;
2,20$&lt;BR /&gt;
3,30$&lt;/P&gt;

&lt;P&gt;Reagrds&lt;BR /&gt;
VG&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 15:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-lookup-csv-file/m-p/326095#M97224</guid>
      <dc:creator>vikas_gopal</dc:creator>
      <dc:date>2018-03-01T15:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to write lookup csv file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-lookup-csv-file/m-p/326096#M97225</link>
      <description>&lt;P&gt;If you have a search that returns only the item you want to append to the lookup file, you can add that event via:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search that returns only events that aren't yet in the file
| outputlookup append=true my_lookup.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your search returns more items than just the one that's currently not present in the file and you want to make sure you only add the new ones, one way to get them both into the file without duplicates is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search that returns events that may or may not already be in the file
| lookup my_lookup.csv empId OUTPUT empId AS found_empId
| where isnull(found_empId)
| outputlookup append=true my_lookup.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are a handful of approaches to the second option; this is only one. The approaches would vary in efficiency based on the size of your data set and the frequency with which you'll be updating the lookup.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 16:44:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-lookup-csv-file/m-p/326096#M97225</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-01T16:44:39Z</dc:date>
    </item>
  </channel>
</rss>

