def setup_example(): # generate OdmlTable object xlstable = odml_xls_table.OdmlXlsTable() # customize odmldtypes to use xlstable.odtypes.add_synonym('string', 'pers') dtypes = xlstable.odtypes # generating odml document with template structure # this could also be done in excel using odmltables odml_doc = get_odml_doc(dtypes) # enter animal specifications in template structure # this would typically be done manually once per animal enrich_animal_specifications(odml_doc) # enter developmental data in template structure # this would typically be done manually on a daily basis using odmltables enrich_developmental_specifications(odml_doc) # load odml structure into odmltable object xlstable.load_from_odmldoc(odml_doc) # adapt header of excel file to be written xlstable.change_header(Path=1, PropertyName=2, Value=3, DataUnit=4, odmlDatatype=5, PropertyDefinition=6) xlstable.write2file('example3.xls') xlstable.write2odml('example3.odml')
def createfile(settings): odmldoc = setup_tutorodml() table = odml_xls_table.OdmlXlsTable() table.load_from_odmldoc(odmldoc) table.changing_point = None table.show_all_sections = False table.show_all_properties = False title_translator = {v: k for k, v in iteritems(table._header_titles)} # mandatory_titles = [title_translator[m] for m in mandatory_headers] # setting custom header columns output_headers = [title_translator[str( settings.get_object('LWselectedcolumns').item(index).text())] for index in list(range(settings.get_object('LWselectedcolumns').count()))] table.change_header( **dict(zip(output_headers, list(range(1, len(output_headers) + 1))))) # table.mark_columns( # *[h for i, h in enumerate(output_headers) if h in mandatory_titles]) # set all styles to plan black and white styles = ['first_style', 'second_style', 'first_marked_style', 'second_marked_style', 'highlight_style'] for style in styles: setattr(getattr(table, style), 'backcolor', 'white') setattr(getattr(table, style), 'fontcolor', 'black') table.highlight_defaults = True # saving file table.write2file(settings.get_object('outputfilename'))
def run_example(): # Generate OdmlXlsTable object xlstable = odml_xls_table.OdmlXlsTable() # Load data from xls xlstable.load_from_xls_table('example1-2.xls') # Save as odml file xlstable.write2odml('example1-2.odml') pass
def run_example(): # generating OdmlXlsTable object xlstable = odml_xls_table.OdmlXlsTable() # loading data from odml xlstable.load_from_file(pre_enriched_file) xlstable.write2file('automatically_enriched.xls') # mimicing manual entry of data in the xls manual_enrichment() xlstable.load_from_xls_table('manually_enriched.xls') xlstable.write2odml('example2-2.odml')
def run_example(): # generating OdmlXlsTable object xlstable = odml_xls_table.OdmlXlsTable() # loading data from xls file xlstable.load_from_xls_table('example3.xls') # filtering only for developmental age and body weight properties xlstable.filter(PropertyName=['DevelopmentalAge', 'Weight'], comparison_func=lambda x, y: (x in y)) # removing templates xlstable.filter(invert=True, Path='template', comparison_func=lambda x, y: x.endswith(y)) xlstable.write2file('example3_Output.xls')
def manual_enrichment(): # mimic manual enrichment of xls doc = automatic_enrichment() surgery_props = doc['Animal']['Surgery'].properties surgery_props['Surgeon'].values = 'Surgeon1' surgery_props['Date'].values = datetime.datetime.today().date() surgery_props['Weight'].values = 100.0 surgery_props['Quality'].values = 'good' surgery_props['Anaesthetic'].values = 'urethane' surgery_props['Painkiller'].values = '' surgery_props['Link'].values = '../../surgery/protocols/protocol1.pdf' xlstable = odml_xls_table.OdmlXlsTable() xlstable.load_from_odmldoc(doc) xlstable.write2file('manually_enriched.xls')
def setup_example(): # We are using the same csv table as used in the tutorial filename = '../../doc/source/csv/example1-2.csv' xlstable = odml_xls_table.OdmlXlsTable() xlstable.load_from_csv_table(filename) # turn off color of table cells basic_style = XlsStyle(backcolor='white', fontcolor='black', fontstyle='') xlstable.highlight_defaults = False xlstable.highlight_style = basic_style xlstable.header_style = basic_style xlstable.first_style = basic_style xlstable.second_style = basic_style xlstable.first_marked_style = basic_style xlstable.second_marked_style = basic_style xlstable.document_info_style = basic_style # saving as file to be comparable to tutorial xlstable.write2file('example1-2.xls')