Splunk® Enterprise

Search Reference

Download manual as PDF

This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Download topic as PDF

outputcsv

Description

Saves search results to the specified CSV file on the local search-head in the $SPLUNK_HOME/var/run/splunk/csv directory. Updates to $SPLUNK_HOME/var/run/*.csv using outputcsv are not replicated across the cluster.

Syntax

outputcsv [append=<bool>] [create_empty=<bool>] [dispatch=<bool>] [usexml=<bool>] [singlefile=<bool>] [<filename>]

Optional arguments

append
Syntax: append=<bool>
Description: If 'append' is true, attempts to append to an existing csv file if it exists or create a file if necessary. If there is an existing file that has a csv header already, only emits the fields that are referenced by that header. .gz files cannot be appended to.
Default: false
create_empty
Syntax: create_empty=<bool>
Description: If set to true and there are no results, creates a 0-length file. When false, no file is created and if append=false, the file is deleted if it previously existed.
Default: false
dispatch
Syntax: dispatch=<bool>
Description: If set to true, refers to a file in the job directory in $SPLUNK_HOME/var/run/splunk/dispatch/<job id>/.
filename
Syntax: <filename>
Description: Specify the name of a csv file to write the search results. This file should be located in $SPLUNK_HOME/var/run/splunk/csv. If no filename specified, rewrites the contents of each result as a CSV row into the "_xml" field. Otherwise writes into a file and appends ".csv" to filename if filename has no existing extension.
singlefile
Syntax: singlefile=<bool>
Description: If singlefile is set to true and output spans multiple files, collapses it into a single file.
Default: true
usexml
Syntax: usexml=<bool>
Description: If there is no filename, specifies whether or not to encode the CSV output into XML. This option should not specified when invoking the outputcsv command from Splunk Web.

Usage

There is no limit to the number of results that can be saved to the CSV file.

Examples

Example 1:

Output search results to the CSV file 'mysearch.csv'.

... | outputcsv mysearch

See also

inputcsv

Answers

Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the outputcsv command.

PREVIOUS
outlier
  NEXT
outputlookup

This documentation applies to the following versions of Splunk® Enterprise: 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.0.9, 6.0.10, 6.0.11, 6.0.12, 6.0.13, 6.0.14, 6.0.15, 6.1, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5, 6.1.6, 6.1.7, 6.1.8, 6.1.9, 6.2.13, 6.2.14, 6.2.15


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters