This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
809f5b5
commit 7fc12aa
Showing
7 changed files
with
436 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
import app | ||
import os,sys | ||
import csv | ||
|
||
splunkhome = os.environ['SPLUNK_HOME'] | ||
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'trackme', 'lib')) | ||
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators | ||
from splunklib import six | ||
|
||
|
||
@Configuration() | ||
class CsvInputCommand(StreamingCommand): | ||
|
||
def stream(self, records): | ||
self.logger.debug('CsvInputCommand: %s', self) # logs command line | ||
|
||
for record in records: | ||
# Extract the value field only | ||
value = [value for value in record.values()][0] | ||
|
||
# Use the CSV dict reader | ||
readCSV = csv.DictReader(value.splitlines(), delimiter=',', quotechar='"') | ||
|
||
# For row in CSV, generate the _raw | ||
for row in readCSV: | ||
yield {'summary': str(row['summary'])} | ||
|
||
dispatch(CsvInputCommand, sys.argv, sys.stdin, sys.stdout, __name__) |
Oops, something went wrong.