################################################################################## #WRITING OUTPUT TO A EXCEL FILE ################################################################################## crime_theme = gpt.Theme(r"D:\Repos\crime-tables-python\crimetheme.yaml") cover = gpt.Cover( cover_label="Notes", title="Nature of crime: personal and other theft", intro=[ "Data tables shown in this workbook relate to the Crime Survey for England and Wales (CSEW)." ], about=[ "The data contained in these tables are from the Crime Survey for England and Wales (CSEW).", "For more information on these data, see the User guide to crime statistics for England and Wales", "These tables have been built using Python and the code is available here – https://github.com/ONS-centre-for-crime-and-justice", "Following a methodological change to the handling of repeat victimisation in the CSEW, these data are not comparable with data published before January 2019. For more information see ‘Improving victimisation estimates derived from the Crime Survey for England and Wales’", "For further information about the Crime Survey for England and Wales (CSEW) and police recorded crime statistics, please email [email protected]", "or write to: ONS Centre for Crime and Justice, Office for National Statistics, Room 2200, Segensworth Road, Titchfield, PO15 5RR" ], contact=[ "Statistical contact: Nick Stripe", "Tel: 01329 444651", "Email: [email protected]" ]) ################################################################################## #WRITING OUTPUT TO A EXCEL FILE ################################################################################## output_directory = Path(r"D:\crimetables_output") wb = gpt.produce_workbook( filename=str(output_directory /
"source": source, "index_columns": index, "annotations": annotations, "notes": notes, } ## Define our GPTable iris_table = gpt.GPTable(table=iris_summary, **kwargs) iris_table_copy = deepcopy(iris_table) iris_table_copy.set_title("A copy of the first sheet$$note2$$") cover = gpt.Cover( cover_label="Notes", title="A Worbook containing good practice tables", intro=["This is some introductory information", "And some more"], about=["Even more info about my data", "And a little more"], contact=["John Doe", "Tel: 345345345"], additional_elements=["subtitles", "scope", "source", "notes"] ) ## Use write_workbook to win! if __name__ == "__main__": output_path = parent_dir / "python_iris_cover_gptable.xlsx" gpt.write_workbook( filename=output_path, sheets={ "Iris Flower Dimensions": iris_table, "Copy of Iris Flower Dimensions": iris_table_copy, }, cover=cover, auto_width=True,