Knowledge Management

How to find CSV issue?

andrew_burnett
Path Finder

We have error messages like " Corrupt csv header in CSV file , 2 columns with the same name 'Severity" & CSV file contains invalid field ''. How do I find this? My SHC has hundreds of CSV files, so it is hard to find issues even with grep.

Labels (1)
0 Karma

stevediaz
Explorer

Hello

To find and fix CSV header errors in multiple files, write a script to check for duplicate column names and invalid fields in the header row. Then, run the script on your CSV file directory.

For Python, a basic example might look like this:

 

import csv
import os

def check_csv_headers(file_path):
with open(file_path, 'r') as csvfile:
csvreader = csv.DictReader(csvfile)
headers = csvreader.fieldnames
if len(headers) != len(set(headers)):
print(f"Duplicate columns in: {file_path}")
if '' in headers:
print(f"Invalid field name in: {file_path}")

# Directory containing CSV files
directory = '/path/to/csv/files'

for filename in os.listdir(directory):
if filename.endswith('.csv'):
file_path = os.path.join(directory, filename)
check_csv_headers(file_path)

Save the script to a file, make it executable (if needed), and run it against your directory containing the CSV files.

python check_csv_headers.py

This approach automates the process of scanning your CSV files for errors and should help you efficiently locate and fix these issues across multiple files within your Splunk Heavy Forwarder.

You can also check https://community.splunk.com/t5/Knowledge-Management/bd-p/knowledge-management/CCSP Certification

Thank you

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

I've only seen those messages in search results so it's pretty easy to check the few lookups in my search.  It becomes more difficult when there are automatic lookups to check.  The search log should have more information, though.

---
If this reply helps you, Karma would be appreciated.
0 Karma

andrew_burnett
Path Finder

It's not in the search results as I get it, rather it's tracked by Mongo and that is how we're seeing it. So I don't have search.log indexed into Splunk and therefore have no visibility. 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I'm not sure what you mean by "tracked by Mongo".  If there a corrupt KVStore lookup then you should be able to scan your collections.conf files for duplicate names, but would think problems there would be reported differently..

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

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

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