Splunk Search

How to write lookup csv file?

vikas_gopal
Builder

Hi Splunk Experts,

I am preparing one POC , here what I want .

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

Splunk Data is
empId,name,deparment,salary
1,vg,finance,10$
2,gv,it,20$
3,abc,IT,30$

lookup file
empId,Salary
1,10$
2,20$

Now I want to update csv using outputlookup command , but only for empid 3 . Please suggest how I can achieve this .

So my outputlookup csv should look like
empId,Salary
1,10$
2,20$
3,30$

Reagrds
VG

0 Karma
1 Solution

elliotproebstel
Champion

If you have a search that returns only the item you want to append to the lookup file, you can add that event via:

your search that returns only events that aren't yet in the file
| outputlookup append=true my_lookup.csv

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:

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

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.

View solution in original post

0 Karma

elliotproebstel
Champion

If you have a search that returns only the item you want to append to the lookup file, you can add that event via:

your search that returns only events that aren't yet in the file
| outputlookup append=true my_lookup.csv

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:

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

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.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...

Keep the Learning Going with the New Best of .conf Hub

Hello Splunkers, With .conf26 getting closer, there’s already a lot of excitement building around this year’s ...