xcsv: read/write CSV files

Defined in xtensor/xcsv.hpp

template<class T, class A = std::allocator<T>>
xcsv_tensor<T, A> xt::load_csv(std::istream &stream, const char delimiter = ',', const std::size_t skip_rows = 0, const std::ptrdiff_t max_rows = -1, const std::string comments = "#")

Load tensor from CSV.

Returns an xexpression for the parsed CSV

  • stream: the input stream containing the CSV encoded values

  • delimiter: the character used to separate values. [default: ‘,’]

  • skip_rows: the number of lines to skip from the beginning. [default: 0]

  • max_rows: the number of lines to read after skip_rows lines; the default is to read all the lines. [default: -1]

  • comments: the string used to indicate the start of a comment. [default: “#”]

template<class E>
void xt::dump_csv(std::ostream &stream, const xexpression<E> &e)

Dump tensor to CSV.

  • stream: the output stream to write the CSV encoded values

  • e: the tensor expression to serialize