simcapluginformat | index c:\umetri\simca\simca16_0\sln\output\simcax64\debugexe\simcapluginformat.py

Classes
`` |  | builtins.object SIMCAFileFormat
class SIMCAFileFormat(builtins.object)
`` | `Abstract base class for making file format add-ins in SIMCA. Example: from umetrics import * from umetrics.impdata import * from simcapluginformat import SIMCAFileFormat class AddInFormat(SIMCAFileFormat): def can_read(self): return True def read(self, file_list, multiple_ok): # Add code to fill in the umetrics.ImportData, for example. # a list of ImportData can be returned if multiple_ok is true, else return only one. import csv ofile = open(file_list[0], "r") try: dialect = csv.Sniffer().sniff(ofile.read(1024)) ofile.seek(0) reader = csv.reader(ofile, dialect) except: ofile.seek(0) reader = csv.reader(ofile, delimiter = ',') your_list = list(reader) data = ImportData(your_list) # optionally set formatting. data.importspec.set_row_type(0, ImportSpecification.rowtype.primaryvarid) data.importspec.set_col_type(0, ImportSpecification.columntype.primaryobsid) ofile.close() return data def merge_multiple_files(self): #return true if the file format takes mutliple files and merges to one dataset, the files argument in read can be a list of files: return False def can_write(self): return True def write(self, Data, file_path): # Add code to save the data, for example. import csv ofile = open(file_path, "w") writer = csv.writer(ofile, delimiter = ',') for row in Data : writer.writerow(row) ofile.close() return True def get_extension(self): return['csv'] def get_name(self): return 'comma separated'`
| Methods defined here: can_read(self) `return True if this format supports reading.` can_write(self) `return True if this format supports writing.` get_extension(self) `return the extension or a list of extensions supported, for example "xls" or ["xlsx", "xlsb"].` get_name(self) `return the name of this file format, for example "Excel" fopr excel files.` merge_multiple_files(self) `return true if the file format takes mutliple files and merges to one dataset, the files argument in read can be a list of files` read(self, file_list, multiple_ok) `Overload to read a file, return the result in an umetrics.ImportData, or a list of ImportData if multiple_ok is True` write(self, Data, file) `Overload to write a file` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` Data and other attributes defined here: __abstractmethods__ = frozenset({'can_read', 'can_write', 'get_extension', 'get_name'})