ReadValues
The ReadValues module allows importing parameters from external files, such as text or Excel files.
Key Features
- Load Complex Parameter Variations: Parameters stored in external files can be used as Sweep Values or Device Parameters.
- Dynamic Device Control: Device settings in SweepMe! can be dynamically adjusted based on the parameters read from these files.
- Supported files: Text files (*.txt, *.csv), Excel files (*.xls, *.xlsx), ini files (*.ini)
Loading and reading a file
Files can be loaded using the button 'Load list'.
Procedure
- Empty lines are automatically skipped.
- Lines starting with a comment character are skipped as well.
- An empty cell is represented by an empty string (""). However, in case the missing character is an empty string, a float('nan') will be generated and shown as 'nan' in the table.
- If desired, the name of the variable and the unit of each column are read from the first available lines (rows).
- If desired, a certain number of lines can be skipped, e.g. to remove a header.
ini files
Variations are not possible when using ini files, instead, the parameters are all read at once. The parameter name is a concatenation of section and option name. E.g. the following ini file
[MySection]
option1 = value1
option2 = value2
creates and sets arameter "MySection-option1" to "value1" and parameter "MySection-option2" to "value2".
Sweep value
The Sweep value of ReadValues is the value of the first column. As the Sweep value of each Module is used to generate the file names of the measured data by MakeFile, the first column of the read-in file is essential for the names of the measurement data files.
Applications
- Load complex parameter variations that are stored in an external file
- Load values from a file to hand them over to various Modules as Sweep value
- Create a configuration file and set Module or Driver settings from the read values using the Parameter_system
- Load previously measured data to evaluate it by using SweepMe! in combination with the module CustomFunction
- Load files to create a template that can be modified by the user later on
- In combination with Condition and Calc you can create conditions for which a measurement is done.
- in progress: Read multiple files in combination with the module LoadFiles to evaluate a bunch of files with similar structure and content.
User interface
Sweep mode
- Each line of file: A single file can be loaded into the module and for each line of your file, the ReadValues module will perform a variation of the modules in the sequencer that are hierarchically below.
has variable
Must be checked if the first non-empty, non-comment line of your file specifies the names of the variables related to each column.
has unit
Only available if 'has variable' is checked. Must be checked if the line after variables indicates the corresponding units.
Delimiter
The character that separates values of each column. It is not needed for excel files.
Comment
Character at the beginning of a line that indicates that this line should be skipped during read-in
Missing data
String that indicates missing data, so that SweepMe! can replace each occurence with a float of 'not-a-number' (nan). Important if data with missing values shall be plotted.
Skip lines
Number of lines that shall be skipped before data is read-in. Empty lines will be automatically skipped.
Preview [lines]
Loading large files can lead to delays that are prevented by showing a preview of the data. Enter the number of lines that you need to make sure that the correct file is loaded and which allows a proper performance.
recognize as GUI elements
If checked, the content of your file will displayed as CheckBox or ComboBox if certain patterns are matched:
- CheckBox: The entry is a string being 'False', 'FALSE', 'True', or 'TRUE'. Booleans in Excel are however loaded as integers (0 or 1) and cannot be interpreted as True or False
- ComboBox: The entry is separaed by '|'
use '^' to copy cell above
If checked, each cell containing a '^' character will get the value of the cell above. Thus, adjacent cell in vertical direction can be related to each other.
editable
If checked, loaded values can be usd as template to modify them before a measurement is done. Please read the section 'Editing values' for further information.
Preview mode
Large files can lead to delays in the program response. For that reason, a preview of typical 100 lines is shown. If your file has more than shown in the preview they will still be used during the measurement. Adjust the option 'Preview [lines]' if you need to see all lines of your file.
Editing values
Editing of values is possible if
- SweepMode is 'Each line of file'
- The entire file is shown, i.e. no preview mode is used
- The option 'editable' is checked.
Changed values will replace the value of the loaded file during a measurement. However, changed values will not permanently saved to the setting or to the selected file. Thus, the loaded file can be used as a template that can be modified each time before a measurement is done.
Disable lines
In case you would like to disable lines to not use them during the measurement, we recommend to use the option 'recognize as GUI elements' and add a column of bool values such as 'False' or 'True' to your file. A CheckBox will be displayed for each bool value that can be checked or unchecked. In combination with the module Condition, measurement points can be skipped that have the property 'False'
Data types
Cell contents are evaluated and changed to python types:
- Float: If all values of a column can be converted by float()
- Integer: If all values of column can be converted by int()
- Boolean: If cells are recognized in Excel as bool value, e.g. TRUE or FALSE, they will be returned integers 0 or 1, respectively. Caution: If these fields are treated as text by Excel e.g. "True" or "False", they will be loaded as string.
- String: All other fields are treated like text fields and a string is returned.
Loading SweepMe! data
Data that was previously been measured with SweepMe! can easily be loaded again with ReadValues. The preset options are already adjusted for that purpose.