Skip to content

[source]

CSV#

A plain-text format that use newlines to delineate rows and a user-specified delimiter (usually a comma) to separate the values of each column in a data table. Comma-Separated Values (CSV) format is a common format but suffers from not being able to retain type information - thus, all data is imported as categorical data (strings) by default.

Note

This implementation of CSV is based on the definition in RFC 4180.

Interfaces: Extractor, Writable

Parameters#

# Name Default Type Description
1 path string The path to the CSV file.
2 header false bool Does the CSV document have a header as the first row?
3 delimiter ',' string The character that delineates the values of the columns of the data table.
4 enclosure '"' string The character used to enclose a cell that contains a delimiter in the body.
5 escape '\' string The character used as an escape character (one character only).

Example#

use Rubix\ML\Extractors\CSV;

$extractor = new CSV('example.csv', true, ',', '"','\\');

Additional Methods#

Return the column titles of the data table.

public header() : array

References#


  1. T. Shafranovich. (2005). Common Format and MIME Type for Comma-Separated Values (CSV) Files.