| |
- open_file_dialog(...)
- Displays a file open dialog and returns a list of selected files and selected file type
The method is almost a plug in replacement for tkFileDialog.askopenfilename but has
support for file types that Satorius Stedim Data Analytics software can read.
Options:
filetypes -- Sets the types in the 'File Types' list box.
Default is [('All files', '.*')]
initialdir -- The initial directory shown in the dialog.
Default is to show the last directory in which
a file was selected or the 'documents' directory
if no file has been previously selected.
initialfile -- Specifies a filename to be displayed in
the dialog when it pops up.
multiple -- Allows the user to choose multiple files from the
Open dialog.
Default is not to allow multi selection (False).
mustexist -- Specifies whether the user may specify non-existent files.
Default is (True)
title -- The text shown in the caption of the dialog.
supportedfiletypes -- Adds all file types that SIMCA can read to
the 'File Types' list box.
Default is to add them (True)
Returns:
A tuple containing a list of the selected files and a string containing
the selected file type.
If the user didn't select any file (pressed cancel), the method returns (None, None).
- read_file(...)
- read_file( (object)files [, (str)filetype='' [, (str)openoptions='']]) -> ImportData :
Reads a file or files and returns the content.
The following file types are supported.
Brimrose Files (*.dat)
Brookside Files (*.trn; *.pkg)
Brookside Ver. 2.6 XML Files (*.xml)
Bruker OPUS File (*.*)
Bruker OPUS Interpolated File (*.*)
CSV Files (*.csv)
DIF Files (*.dif)
Excel 97-2003 Workbook (*.xl*)
Excel Workbook (*.xlsx; *.xlsb)
Galactic SPC Files (*.spc)
HPLC ChemStation Files (*.ch, *.uv)
JCAMP-DX Files (*.jcm; *.dx; *.jdx)
Lotus 1-2-3 Files (*.wks; *.wk1)
MODDE Files (*.mip; *.dat)
Matlab Files (*.mat)
NSAS Files (*.da)
NetCDF Files (*.nc; *.cdf) (MVACDF, ANDI)
SIMCA project file (*.usp)
Text Files (*.txt; *.dat)
Thermo SIEVE Files (*.txt)
Unscrambler Files (*.uns; *.inp)
Arguments:
files -- A list containing the paths(s) of the file(s) to read.
filetype -- This string is usually obtained from SelectFileDialog.open_file_dialog()
and is used to determine the file type. If omitted (or unrecognized) SIMCA will try
to determine the file type from the files content and extension.
openoptions -- An XML formatted string containing file type specific options for reading files
It can for example be text file encoding, decimal separator or excel worksheet name
All files types expects a root section call "Settings" With options in the attributes
Excel.
"Sheets" is a semicolon separated list of worksheet names
"ReadOrder" can be 1 to merge above/below or 2 to merge side by side, default 1
"AllSheets" 1 to import all sheets, 0 to import those specified by the sheets option, default 0
"UseIndexes" 1 if the sheets option is worksheet indexes, 0 if it is worksheet names, default 0
Example: <Settings ReadOrder=\"1\" Sheets=\"WSName1;WSName2;WSName3\" UseIndexes=\"0\" AllSheets=\"0\"/>
or
<Settings ReadOrder=\"2\" Sheets=\"0;1;3\" UseIndexes=\"1\" AllSheets=\"0\"/>
SIMCA USP
"Sheets" is the dataset name to import
Example: <Settings Sheets=\"DatasetName\"/>
DIF
Encoding is the locale names, valid locales are
ibm420, iso88596, windows1256, iso88592, windows1250, gb18030, iso2022cn, big5, iso88595, koi8r, windows1251, iso88597, windows1253, ibm424, iso88598, windows1255, eucjp, iso2022jp, shiftjis, euckr, iso2022kr, , iso88599, windows1254, utf16be, utf16le, utf32be, utf32le, utf8, cp850, iso88591 and windows1252
Example: <Settings Encoding=\"iso88592\"/>
CSV
Encoding is the same as for DIF files
Delimiter is the delimiter used to separate values.
comma and cp1252
Example: <Settings Delimiter=\",\" Encoding=\"cp1252\"/>
or with tab and utf8
<Settings Delimiter=\"	\" Encoding=\"utf8\"/>
Text
Same as CSV with the addition of ...
IgnoreConsecutiveDelimiters, which can have the value 0 for false and 1 for true
Example: <Settings Delimiter=\"-\" Encoding=\"gb18030\" IgnoreConsecutiveDelimiters=\"0\"/>
Galactic SPC
IncludeOrdinalValues, Value 0 for false and 1 for true. If 1, the ordinal values (wavelengths etc) will be included as a row.
IncludeAllValues, Value 0 for false and 1 for true
IncludeXStartPt, Semicolon separated list of start points, empty when IncludeAllValues is 1
IncludeXEndPt, Semicolon separated list of end points, empty when IncludeAllValues is 1
NumberOfIncludedIntervals, the lengt of the two lists above, 0 when IncludeAllValues is 1
UseAverage, integer value >=0 the length between each point when averaging, 0 when IncludeAllValues is 1 or when averaging is not to be used.
examples
<Settings IncludeOrdinalValues=\"1\" IncludeAllValues=\"1\" IncludeXEndPt=\"\" IncludeXStartPt=\"\" NumberOfIncludedIntervals=\"0\" UseAverage=\"0\"/>
<Settings IncludeOrdinalValues=\"0\" IncludeAllValues=\"0\" IncludeXEndPt=\"5000;5058\" IncludeXStartPt=\"3929.43;5001.43\" NumberOfIncludedIntervals=\"2\" UseAverage = \"2\"/>
JCAMP-DX
DataBlocks is a semicolon separated list of indexes of the series to include. Note that the first index is 0
InterPolationFile and InterPolationSerie is the index of the file and the index of the series in that file
that is to be used as template if input needs to be interpolated.
The data needs to be interpolated if the series are of different length and/or they start/end at different points.
After interpolation, all series will have the same ordinal values as the selected series.
These two options are optional and are defaulted to the first series in the first file.
Example: <Settings InterPolationFile=\"0\" InterPolationSerie= \"0\" DataBlocks=\"0;4;6\"/>
Unscrambler files
Encoding is the locale names, valid locales are
ibm420, iso88596, windows1256, iso88592, windows1250, gb18030, iso2022cn, big5, iso88595, koi8r, windows1251, iso88597, windows1253, ibm424, iso88598, windows1255, eucjp, iso2022jp, shiftjis, euckr, iso2022kr, , iso88599, windows1254, utf16be, utf16le, utf32be, utf32le, utf8, cp850, iso88591 and windows1252
|