spectrochempy.read_csv¶
- read_csv(*paths, **kwargs)[source]¶
Open a *.csv file or a list of *.csv files.
This is limited to 1D array - csv file must have two columns [index, data] without header.
- Parameters
*paths (str, pathlib.Path object, list of str, or list of pathlib.Path objects, optional) – The data source(s) can be specified by the name or a list of name for the file(s) to be loaded:
e.g.,( file1, file2, …, **kwargs )
If the list of filenames are enclosed into brackets:
e.g., ( [ file1, file2, … ], **kwargs )
The returned datasets are merged to form a single dataset, except if
merge
is set to False. If a source is not provided (i.e. nofilename
, norcontent
), a dialog box will be opened to select files.**kwargs – Optional keyword parameters (see Other Parameters).
- Returns
- Other Parameters
directory (str, optional) – From where to read the specified
filename
. If not specified, read in the defaultdatadir
specified in SpectroChemPy Preferences.merge (bool, optional) – Default value is False. If True, and several filenames have been provided as arguments, then a single dataset with merged (stacked along the first dimension) is returned (default=False).
sortbydate (bool, optional) – Sort multiple spectra by acquisition date (default=True).
description (str, optional) – A Custom description.
origin ({‘omnic’, ‘tga’}, optional) – in order to properly interpret CSV file it can be necessary to set the origin of the spectra. Up to now only ‘omnic’ and ‘tga’ have been implemented.
csv_delimiter (str, optional) – Set the column delimiter in CSV file. By default it is the one set in SpectroChemPy
Preferences
.content (bytes object, optional) – Instead of passing a filename for further reading, a bytes content can be directly provided as bytes objects. The most convenient way is to use a dictionary. This feature is particularly useful for a GUI Dash application to handle drag and drop of files into a Browser. For examples on how to use this feature, one can look in the
tests/tests_readers
directory.listdir (bool, optional) – If True and filename is None, all files present in the provided
directory
are returned (and merged ifmerge
is True. It is assumed that all the files correspond to current reading protocol (default=True).recursive (bool, optional) – Read also in subfolders. (default=False).
See also
read_topspin
Read TopSpin Bruker NMR spectra.
read_omnic
Read Omnic spectra.
read_opus
Read OPUS spectra.
read_spg
Read Omnic *.spg grouped spectra.
read_spa
Read Omnic *.Spa single spectra.
read_srs
Read Omnic series.
read_zip
Read Zip files.
read_matlab
Read Matlab files.
read
Generic file reading.
Examples
>>> scp.read_csv('agirdata/P350/TGA/tg.csv') NDDataset: [float64] unitless (shape: (y:1, x:3247))
Additional information can be stored in the dataset if the origin is given (known origin for now : tga or omnic) # TODO: define some template to allow adding new origins
>>> scp.read_csv('agirdata/P350/TGA/tg.csv', origin='tga') NDDataset: [float64] wt.% (shape: (y:1, x:3247))
Sometimes the delimiteur needs to be adjusted
>>> prefs = scp.preferences >>> scp.read_csv('irdata/IR.CSV', directory=prefs.datadir, origin='omnic', csv_delimiter=',') NDDataset: [float64] a.u. (shape: (y:1, x:3736))