Hi ,
Am a beginner in python , you could consider this as my 1st project.
So at work we consolidate excel sheets a lot , and as a temp i would be tasked to it always!
Copying and pasting over and over again got to me think if it can be automated with programming . Looks like there is , but i wished to do it with python since i am learning it.
so i tried and got till here searching the web.
#Program to combine excel sheets from same excel workbook.
import pandas pas pd
import numpy as np
excel_file_1 = ‘workbook1.xlsx’
df_Day_one = pd.read_excel(excel_file_1, sheet_name=‘Sheet1’)
df_Day_2 = pd.read_excel(excel_file_1, sheet_name=‘Sheet2’)
df_all = pd.concat([df_Day_one,df_Day_2])
df_all.to_excel(“two_days_output.xlsx”)
This is working and am happy and proud about it even tho it took me 3 days to get this code working… had problems with the location… of the excel sheet .
But sadly i need to do it for 30 days so yes 30 sheets typing ""sheet_name = “” for every sheet, it just beats the whole objective of “less work”.
So searched a bit more and found that “” pd.read_excel(excel_file,sheet_name=None) “” would read all the data ? so i tried it like this and…
import pandas as pd
import numpy as np
excel_file=‘FSL Dump for August.xlsx’
df_alldays = pd.read_excel(excel_file,sheet_name=None)
df_alldays.to_excel(‘16_days_output.xlsx’)
This is the error am getting in shell
File “<pyshell#50>”, line 1, in
df_alldays.to_excel(“16_days_output.xlsx”)
AttributeError: ‘dict’ object has no attribute ‘to_excel’
And this is the part where am stuck at , tried searching the web and still havent got to anything . Need help with this .
Have a good day