src.Libs.FileIO package
Submodules
src.Libs.FileIO.FileDataClass module
This file is part of the PAFFrontendSim.
The PAFFrontendSim is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3 as published by the Free Software Foundation.
The PAFFrontendSim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the PAFFrontendSim. If not, see https://www.gnu.org/licenses/.
- class src.Libs.FileIO.FileDataClass.FileData(log=None, headerProfile={'DUT': [0, 'U', '', 'Device under test'], 'Date': [0, 'S', '', 'Date of data taking'], 'Device': [1, 'U', '', 'Device name / ID'], 'Operator': [0, 'U', '', 'Operator name / ID'], 'Version': [1, 'U', '', 'File Version'], '_ACCURACY': 5, '_ADDUNKNOWN': False, '_COMMENT': '#', '_CONFIG_TYPE': 'TEMPERATURES', '_Comment1': 'File description:', '_Comment2': 'Data descriptionn:', '_DELMITTER': ' ', '_EMPTY': 2, '_HEADERINDICATOR': '################################################################################', '_KEYINDICATOR': ':', '_LENGTH': 10, '_NAME': 'Default File Header profile', '_ReadFunction': None, '_SCIENTIFIC': '', '_UPPERCASE': True, '_WriteFunction': None})[source]
Bases:
object
This module (and specifically this class) provides a simple interface for other modules to read and write data to files. The header information and file structure only need to be passed once. Subsequent read and write operations can be performed by using the methods readData and writeData.
Initialize class.
- createEmptyResult()[source]
creates an empty result dictionary with all header entries set to default values.
- Returns:
resultDict (dict) – empty result dictionary with all header entries set to default values
- parseHeader(filename)[source]
Getting all header data from file with filename ‘filename’.
- Parameters:
filename (string) – path of file
- Returns:
dictionary (dict) – dictionary of results
- parseLine(line)[source]
Parsing a given string according to the header.
- Parameters:
line (string) – The line to parse
- Returns:
tuple (tuple) – boolean flag indicating success or failure, Keyword-string (“ERROR:” in case of an error, “WARNING:” in case of a warning), list of parameters (list with one string holding the error message in case of an error)
- printOut(line, message_type, noSpace=True, lineFeed=True)[source]
Wrapper for the printOut method of the actual log class
- readData(filename, delmitter=None, noColumns=0, tryFloat=True)[source]
Reads data array from disk.
- Parameters:
filename (string) – path of the file to write to
delmitter (string) – characters between the entries
NoColumns (int) – maximal number of columns to consider
tryFloat (boolean) – indicating if a pure string array is returned (False) or if the entries are tried to be interpreted as floats (True)
- Returns:
tuple (tuple) – headerDict (dict with header data), data (array with data)
- writeData(filename, data, header=None, delmitter=' ', accuracy=4, length=10, dataDescription='')[source]
writes data array to disk.
- Parameters:
filename (string) – path of the file to write to
data (2D-array) – array containing the data
header (dict) – header data; if None, no header is written
delmitter (string) – characters between the entries
accuracy (int) – number of digits for float numbers
length (int) – field length (minimal)
dataDescription (string) – data line description string, if empty, nothing is written
src.Libs.FileIO.constants module
This file is part of the PAFFrontendSim.
The PAFFrontendSim is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3 as published by the Free Software Foundation.
The PAFFrontendSim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the PAFFrontendSim. If not, see https://www.gnu.org/licenses/.
Module contents
This file is part of the PAFFrontendSim.
The PAFFrontendSim is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3 as published by the Free Software Foundation.
The PAFFrontendSim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the PAFFrontendSim. If not, see https://www.gnu.org/licenses/.