Skip to content

Instantly share code, notes, and snippets.

@songokjesse
Last active October 26, 2020 10:45
Show Gist options
  • Save songokjesse/7c547d3afa849fc29df2e2583f53544e to your computer and use it in GitHub Desktop.
Save songokjesse/7c547d3afa849fc29df2e2583f53544e to your computer and use it in GitHub Desktop.
Creating a new google sheet workbook and transferring pandas dataframe data
def createMasterListWorkSheet():
# get cleaned data from the RemoveDuplicateData Function
newData = RemoveDuplicateData()
# get the row count from the dataframe and convert to type int so as to be serialized to json (Produces error if not converted)
rowCount = int(newData['hits'].count())
# create a new sheet
sheet.add_worksheet(title="MASTER_LIST", cols=6, rows=rowCount + 1)
# Get the instance
newSheet = sheet.worksheet("MASTER_LIST")
# Insert the cleaned data
newSheet.insert_rows(newData.values.tolist())
# # Insert headers to the masterlist worksheet by calling the InsertHeader Function
createWorksheetHeader(newSheet)
print("Successfully Created MASTER LIST Worksheet")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment