This is development documentation. Some features are not available in the stable release. View stable documentation.

spectrochempy.write_csv

write_csv(*args, **kwargs)[source]

Write a dataset in CSV format.

Currently only implemented for 1D datasets or ND datasets with only one dimension of length larger than one.

Parameters:
  • filename (str or pathlib object, optional) – If not provided, a dialog is opened to select a file for writing.

  • directory (str, optional) – Where to write the specified filename . If not specified, write in the current directory.

  • delimiter (str, optional) – Set the column delimiter in CSV file. By default it is ‘,’ or the one set in SpectroChemPy Preferences .

  • **kwargs – Additional keyword arguments accepted by the generic writer API. This specialized writer always exports CSV files. Deprecated generic writer kwargs such as protocol= and description= still emit a DeprecationWarning; removal remains warning-first and is governed by the SpectroChemPy deprecation lifecycle policy.

Returns:

out (pathlib object) – Path of the saved file.

Examples

>>> ds = scp.NDDataset([1, 2, 3])
>>> f1 = ds.write_csv('myfile')
>>> ds = scp.read('irdata/nh4y-activation.spg')
>>> f2 = ds[0].write_csv('single_spectrum.csv')

Using the explicit namespace API >>> f3 = scp.csv.write(ds, ‘myfile’)