import pandas as pd
import os
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
path=os.getcwd()
files=os.listdir(path)
for i in range(len(files)):
filename = files[i]
filepath=os.path.join(path,filename)
print(filepath)
df=pd.ExcelFile(filepath) # read sheet name
sheet = df.sheet_names
print(sheet)
df=pd.read_excel(filepath, sheet_name=sheet,skiprows = 5, nrows=15, usecols = 'E:L')
print(df)
CodePudding user response:
import openpyxl
wb = openpyxl.load_workbook('ds.xlsx')
ws = wb.active
for row in ws.iter_rows():
for cell in row:
# only relevant column and without header
if cell.column_letter == 'A' and cell.row > 1: # put the cell number from where to where you want to check
ws[cell.coordinate].number_format = '0.0000000' # it will change the number format
wb.save('ds2.xlsx')