I have used the following code to generate a dataframe:
dataframe_for_excel_file_structure = {'Date': date_for_each_sheet, 'Type of
property': pd.Series(type_of_property), 'Area': pd.Series(sqm_area), 'Location':
pd.Series(locations), 'Price per m2': pd.Series(price_per_m2), 'Total Price':
pd.Series(prices), 'Published by': pd.Series(publisher), 'link':
pd.Series(link_for_offer)}
dataframe_for_excel = pd.DataFrame(dataframe_for_excel_file_structure)
I have also used:
filename_for_sqm = time.strftime("%Y%m%d")
dataframe_for_excel.to_excel(filename_for_sqm + '.xlsx')
to generate my excel file.
My question is once I have created the file, I do not want to create new once, I want to append the current one with more information on a daily basis.
I looked through a couple of threads and the best solution so far (but still doesn't work for me) is:
def append_excel_file():
with open('C:\Users\tsvet\Desktop\20211109.xlsx', 'a+') as f:
f.append(dataframe_for_excel)
This code however causes an error. Do you guys have any suggestions on how I can append my excel file in order to keep on adding data on a daily basis? I do not need the headers I already have them from the first excel file generation.
My idea is to have one .py file that I will run only the first time, after that, I will have a second file that I will run from the second day onwards that will contain this append file function.