pygsheets
pygsheets copied to clipboard
Applying many heterogenous formats to columns is annoying.
Is your feature request related to a problem? Please describe.
Calculating offsets and looping over the columns is rather tedious.
Formatting the dataframe programmatically is part of my workflow for creating
reproducible reports. Since the reports may have varying lengths, having to
calculate offsets etc. each time is annoying.
Describe the solution you'd like I've been using my own fork on top of pygsheets to declare column-level formats and apply them at write time.
Like this:
NUMBER_FORMATS = {
'COUNT': SheetsNumberFormat(FormatType.NUMBER, "#,##0"),
'DOLLAR': SheetsNumberFormat(FormatType.CURRENCY, "$#,##0"),
}
pldf = PlacedDataFrame(df,
column_formats={'money': NUMBER_FORMATS['DOLLAR'], 'count': NUMBER_FORMATS['COUNT']},
index_columns=0)
url = pldf.write_to_new_sheet(folder_hash,
sheet_name=sheet_name,
worksheet_name=worksheet_name
google_client=pygsheets.authorize(service_file=f.name))
I could put it into a PR if you are interested and we could discuss what changes you'd like?
Any other info
looks interesting. we can add a new arg which specifies the formats for each column.
This could be in future extended to applying more cell properties (like validation, color) since apply_format is generic.
Great. I'll extract what I can and submit a PR.