Function Reference by Module¶
Here you find a detailed documentation of the code.
Flattened odML table¶
-
class
odml_table.
OdmlDtypes
(basedtypes_dict=None, synonyms_dict=None)[source]¶ Class to handle odml data types, synonyms and default values.
Parameters: basedtypes_dict – Dictionary containing additional basedtypes to - use as keys and default values as values.
- Default: None
Parameters: synonyms_dict – Dictionary containing additional synonyms to use as - keys and basedtypes to associate as values.
- Default: None
Returns: None
-
class
odml_table.
OdmlTable
(load_from=None)[source]¶ Class to create tables in different formats from odml-files
Parameters: - show_all_sections (bool) – if set to False, information about the section like the path or name of the section wont be in the table again, if they are same as in the line before
- show_all_properties (bool) – if set to False, information about the property like the name or definition of the property wont be in the table again, if they are same as in the line before tables with an emptycolumn
-
change_header
(**kwargs)[source]¶ Function to change the header of the table.
The keywordarguments of the function are the possible columns you can include into your table; they are listed below, you can also check the possible options bei looking at the keys of the header_titles dictionary. They take the number of their position in the table, starting from left with 1. The default-header is [‘Path’, ‘Property Name’, ‘Value’, ‘odML Data Type’]. These are the columns you need to be able to convert your table back to an odml-file. Important: You can create tables wich dont contain any of those four, but they cant be converted back to odml.
Parameters: - Path (int, optional) – Position of the ‘Path’-Column in the table.
- SectionName (int, optional) – Position of the ‘Section Name’-Column in the table
- SectionType (int, optional) – Position of the ‘Section Type’-Column in the table
- SectionDefinition (int, optional) – Position of the ‘Section Definition’-Column in the table
- PropertyName (int, optional) – Position of the ‘Property Name’-Column in the table
- PropertyDefinition (int, optional) – Position of the ‘Property Definition’-Column in the table
- Value (int, optional) – Position of the ‘Value’-Column in the table
- ValueDefinition (int,) – Position of the ‘Value Definition’-Column in the table
- DataUnit (int, optional) – Position of the ‘Data Unit’-Column in the table
- DataUncertainty (int, optional) – Position of the ‘Data Uncertainty’-Column in the table
- odmlDatatype (int, optional) – Position of the ‘odML Data Type’-Column in the table
Example: - mytable.change_header(Path=1, Value=3, odmlDataType=2)
=> outcoming header: [‘Path’, ‘odML Data Type’, ‘Value’]
-
change_header_titles
(**kwargs)[source]¶ Function to change the Name of a column in your table. Be careful with this function if you want to convert the table back to an odml.
Parameters: - Path (string, optional) – Name of the ‘Path’-Column in the table
- SectionName (string, optional) – Name of the ‘Section Name’-Column in the table
- SectionType (string, optional) – Name of the ‘Section Type’-Column in the table
- SectionDefinition (string, optional) – Name of the ‘Section Definition’-Column in the table
- ProgertyName (string, optional) – Name of the ‘Property Name’-Column in the table
- PropertyDefinition (string, optional) – Name of the ‘Property Definition’-Column in the table
- Value (string, optional) – Name of the ‘Value’-Column in the table
- ValueDefinition (string, optional) – Name of the ‘Value Definition’-Column in the table
- DataUnit (string, optional) – Name of the ‘Data Unit’-Column in the table
- DataUncertainty (string, optional) – Name of the ‘Data Uncertainty’-Column in the table
- odmlDatatype (string, optional) – Name of the ‘odML Data Type’-Column in the table
-
consistency_check
()[source]¶ check odmldict for consistency regarding dtypes to ensure that data can be loaded again.
-
convert2odml
()[source]¶ Generates odml representation of odmldict and return it as odml document. :return:
-
filter
(mode='and', invert=False, recursive=False, comparison_func=<function <lambda>>, **kwargs)[source]¶ filters odml properties according to provided kwargs.
Parameters: mode – Possible values: ‘and’, ‘or’. For ‘and’ all keyword - arguments
- must be satisfied for a property to be selected. For ‘or’ only one of the keyword arguments must be satisfied for the property to be selected. Default: ‘and’
Parameters: - invert – Inverts filter function. Previously accepted properties are rejected and the other way round. Default: False
- recursive – Delete also properties attached to subsections of the mother section and therefore complete branch
- comparison_func – Function used to compare dictionary entry to keyword. Eg. ‘lambda x,y: x.startswith(y)’ in case of strings or ‘lambda x,y: x in y’ in case of multiple permitted values. Default: lambda x,y: x==y
- kwargs – keywords and values used for filtering
Returns: None
-
static
get_csv_header
(load_from)[source]¶ Providing non-empty csv header entries of first sheet for odml tables gui only :return:
-
static
get_xls_header
(load_from)[source]¶ Providing non-empty xls header entries of first sheet for odml tables gui only :return:
-
load_from_csv_table
(load_from)[source]¶ loads the odmldict from a csv-file containing an odml-table. To load the odml, at least Value, Path, PropertyName and odmlDatatype must be given in the table. Also, the header_titles must be correct
Parameters: load_from (string) – name(path) of the csv-file
-
load_from_file
(load_from)[source]¶ loads the odml-data from an odml-file
Parameters: load_from (string) – the path to the odml-file
-
load_from_function
(odmlfct)[source]¶ loads the odml-data by using a function that creates an odml-document
Parameters: load_from (function) – function that returns an odml-document
-
load_from_odmldoc
(doc)[source]¶ loads the odml-data from an odml-document
Parameters: load_from (odml-document) – the odml-document
-
load_from_xls_table
(load_from)[source]¶ loads the odml-data from a xls-file. To load the odml, at least Value, Path, PropertyName and odmlDatatype must be given in the table. Also, the header_titles must be correct
Parameters: load_from (string) – name(path) of the xls-file
-
class
odml_csv_table.
OdmlCsvTable
(load_from=None)[source]¶ Class to create a csv-file from an odml-file
-
write2file
(save_to)[source]¶ writes the data from the odml-file to a csv-file. Each line of the table represents one Value of the odml-file. By changing the header of the table you can choose, which informations about those values will be shown in the table. You can also decide, not to include information about every specific value in your header, for example if you just want to get an overview of your odml-structur. Then rows, that would be empty will be skipped and not printed in the table.
Parameters: save_to (string) – name of the csv-file
-
-
class
odml_xls_table.
OdmlXlsTable
(load_from=None)[source]¶ Class to create a csv-file from an odml-file
Parameters: - sheetname (string) – name of the excel sheet; default is ‘sheet1’
- header_style (XlsStyle) – style used for the header of the table
- first_style (XlsStyle) – default style used for the rows
- second_style (XlsStyle) – used to switch styles of the rows if changing_point is not None
- first_marked_style (XlsStyle) – default style used in marked columns
- second_marked_style (XlsStyle) – used to switch styles of the rows in marked columns if changing_point is not None
- pattern (string) – can be ‘alternating’ or ‘checkerboard’
- changing_point (string) – select the point for changing styles. this can be when a new section, property or value starts (‘sections’, ‘properties’, ‘values’ or None)
-
mark_columns
(*args)[source]¶ choose the columns of the table you want to highlight by giving them another style (for example a different color). Possible Arguments are:
- ‘Path’
- ‘SectionName’
- ‘SectionType’
- ‘SectionDefinition’
- ‘PropertyName’
- ‘PropertyDefinition’
- ‘Value’
- ‘ValueDefinition’
- ‘DataUnit’
- ‘DataUncertainty’
- ‘odmlDatatype’.
Comparative Tables¶
-
class
compare_section_table.
CompareSectionTable
[source]¶ class to create a table in which you compare different sections of a odml- file wich have the same properties
Parameters: - include_all (bool) – if set to false, only those properties which exist in every chosen section will be shown
- switch (bool) – when set to True, the table will be switched so the sections are in the rows and the properties in the columns
-
choose_sections
(*args)[source]¶ choose all sections out of the list of sectionnames you give this function
Parameters: args (strings) – names of the sections Example: a.choose_sections(‘section1’, ‘section2’, ‘section4’)
-
choose_sections_startwith
(startwith)[source]¶ choose all sections with the same beginning
Parameters: startwith (string) – beginning of the sectionname of the sections that will be compared
-
class
compare_section_xls_table.
CompareSectionXlsTable
[source]¶ class to write a CompareSectionTable to a xls-file
Parameters: - sheet_name (string) – name of the excel-sheet, default is ‘sheet1’
- header_style (XlsStyle) – style used for the header
- first_style (XlsStyle) – style used for the values inside the table
- second_style (XlsStyle) – second style used for the values inside the table
- missing_value_style (XlsStyle) – if include_all is True, this style will be used if a property doesnt exist in the section, so they distinguish from properties with empty values