domdf_spreadsheet_tools

Tools for creating and formatting spreadsheets with Python and OpenPyXL

domdf_spreadsheet_tools.append_to_xlsx(csv_input_file, xlsx_output_file, sheet_title=None, separator=',', overwrite=False, use_io=False, toFloats=False)[source]

Add CSV file to xlsx file as a new worksheet

Parameters
  • csv_input_file (str or pathlib.Path or os.PathLike) – filepath of CSV file to

  • xlsx_output_file (str or pathlib.Path or os.PathLike) – filepath of xlsx file

  • sheet_title (str, optional) – Title of sheet to append. Default is the value of csv_input_file

  • separator (str, optional) – Separator for reading CSV file. Default ,

  • overwrite (bool, optional) – Whether to overwrite the xlsx output file (i.e. create a new file containing just the new sheet). Default False

  • use_io (bool, optional) – Whether to use the io module. Default False

  • toFloats (bool, optional) – Whether to read strings with thousand separators as floats. Default False

Return type

None

domdf_spreadsheet_tools.format_header(ws, alignment_list, start_row=1, end_row=1)[source]

Format the alignment of the header rows of a worksheet

Parameters
  • ws (openpyxl.worksheet.worksheet.Worksheet) – The worksheet to format

  • alignment_list (Dict[str, str]) – dictionary of alignments (left, right, center) for each column letter

  • start_row (int, optional) – The row to start formatting on. Default 1

  • end_row (int, optional) – The row to end formatting on. Default 1

domdf_spreadsheet_tools.format_sheet(ws, number_format_list=None, width_list=None, alignment_list=None)[source]

Format columns of an xlsx worksheet

Parameters
  • ws (openpyxl.worksheet.worksheet.Worksheet) – The worksheet to format

  • number_format_list (Optional[Dict[str, str]]) – dictionary of number format strings for each column letter

  • width_list (Optional[Dict[str, float]]) – dictionary of widths for each column letter

  • alignment_list (Optional[Dict[str, str]]) – dictionary of alignments (left, right, or center) for each column letter

domdf_spreadsheet_tools.make_column_property_dict(indict, outdict=None, offset_dict=None, repeat=1, length=1)[source]

Generate property lists from integer values

Parameters
  • indict (dict) – Property values to add to the property dict

  • outdict (dict) – Dictionary of properties for each column letter

  • offset_dict

  • repeat (int, optional) – Default 1

  • length (int, optional) – Default 1

TODO: Finish this docstring; check usage in GunShotMatch

Returns

Return type