Splunk Search

Import a matrix

youngsuh
Contributor

Q1:  is there a way to import a matrix into Splunk? 

Q2:  What SPL command gives me all values set to true and tells me x, y coordinates?  (object here is to create table)

Here is an example of the matrix that I would like to import.  (Q3:  What would be SPL command provided the field name for the x, y that is true)

 abcdef
1010110
2101001
3010110
4101110
5011011
6101010
Labels (5)
Tags (5)
0 Karma
1 Solution

tscroggins
Champion

You'll need to give the first column a name, e.g. row:

rowabcdef
1010110
2101001
3010110
4101110
5011011
6101010

 

Next, convert the table to comma separated values:

row,a,b,c,d,e,f
1,0,1,0,1,1,0
2,1,0,1,0,0,1
3,0,1,0,1,1,0
4,1,0,1,1,1,0
5,0,1,1,0,1,1
6,1,0,1,0,1,0

Save the contents to a file, e.g. youngsuh_matrix.csv, and upload the file to Splunk as a lookup from Settings > Lookups. Click + Add New next to Lookup table files.

Finally, run this search:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1

For "x, y" coordinates:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1
| eval coord=row.", ".column
| table coord

coord
1, b
1, d
1, e
2, a
2, c
2, f
3, b
3, d
3, e
4, a
4, c
4, d
4, e
5, b
5, c
5, e
5, f
6, a
6, c
6, e

 

View solution in original post

tscroggins
Champion

You'll need to give the first column a name, e.g. row:

rowabcdef
1010110
2101001
3010110
4101110
5011011
6101010

 

Next, convert the table to comma separated values:

row,a,b,c,d,e,f
1,0,1,0,1,1,0
2,1,0,1,0,0,1
3,0,1,0,1,1,0
4,1,0,1,1,1,0
5,0,1,1,0,1,1
6,1,0,1,0,1,0

Save the contents to a file, e.g. youngsuh_matrix.csv, and upload the file to Splunk as a lookup from Settings > Lookups. Click + Add New next to Lookup table files.

Finally, run this search:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1

For "x, y" coordinates:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1
| eval coord=row.", ".column
| table coord

coord
1, b
1, d
1, e
2, a
2, c
2, f
3, b
3, d
3, e
4, a
4, c
4, d
4, e
5, b
5, c
5, e
5, f
6, a
6, c
6, e

 

youngsuh
Contributor

 Encountered the following error while trying to save: File has no line endings 

any suggestions?

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The multikv command will read that table, but it will convert each row into a separate event so the table will no longer be a table.  I'm not aware of any command that will treat the table as an object and there certainly is no command that will return all the 1's in the table.  This could be an opportunity to create an external command.

---
If this reply helps you, Karma would be appreciated.
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!

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...

Upgrade Prep for 10.4, Network Observability Deep Dives, and More from Splunk Lantern

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Splunk Developer Day announcements: AI agents, MCP tools, Forecasting, and Custom ...

Splunk Developer Day was packed with product and platform updates for developers building in the AI ...