danfo.toCSV
Writes a DataFrame or Series to CSV format.
Last updated
Writes a DataFrame or Series to CSV format.
Last updated
danfo.toCSV(data, options)
The toCSV function can be used to write out a DataFrame or Series to CSV file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a CSV file from Node and Browser environments.
Writing a CSV file to a local file path is only supported in the Nodejs environment
You can automatically convert and download a CSV file in a browser environment, by specifying a fileName
and setting download
to true.
Parameters
Type
Description
Default
data
Series or DataFrame
The Series or DataFrame to write to CSV
options
object, optional
Configuration object:
{
filePath
: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName
: The name of the file to download as. Only needed in browser environment.
download
: Boolean indicating whether to automatically download the CSV file in the browser. Only needed in the browser environment.
header
: Boolean indicating whether to include a header row in the CSV file.
sep
: Character to be used as a separator in the CSV file.
}
{ download: false, sep: "," }