Splunk Search

How to correlate 3 different CSV files with different column names?

krishnacasso
Path Finder

I have 3 different source CSV (file1, file2, file3) files.
In file 1, I have field(place) with value NJ and
In file 2, I have a field(city) with value NJ.
NJ is unique value in file 1 and file 2. I need to merge field names to City.
In file 2, I have a field(country) with value USA and
In file 3, I have a field(origin) with value USA.
USA is unique value in file 2 and file 3. I need to merge field names to Country.

I am trying to correlate the fields and join them and create a single table.

0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

source=csv1 OR source=csv2 OR source=csv3
| eval city=coalesce(city,place) | eval country=coalesce(country, origin)
| eventstats values(country) as country by city 
| eventstats values(city) as city by country
| stats values(field1) as field1 values(field2) as field2... by city country

View solution in original post

surakshita
New Member

I also same type question. I have 3 excel files generating from the servers as reports,two files are in same format and one file has different columns. I wanted to consolidate 3 files and need to analyze for start time and start date for the job.Can anyone give us the inputs on this?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this.

| inputlookup file1.csv | lookup file2.csv city AS place | lookup file3.csv origin AS country | eval City=coalesce(place, city), Country=coalesce(country,origin) | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

krishnacasso
Path Finder

Can we add a condition to the search like to display the chart only for the Manhattan city and USA

0 Karma

somesoni2
Revered Legend

Try something like this

source=csv1 OR source=csv2 OR source=csv3
| eval city=coalesce(city,place) | eval country=coalesce(country, origin)
| eventstats values(country) as country by city 
| eventstats values(city) as city by country
| stats values(field1) as field1 values(field2) as field2... by city country
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...