I can read multiple excel files in a folder by using os:
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
import os
import pandas as pd
import math
folder = r'C:\Users\Denny\Desktop\Work\test_read'
files = os.listdir(folder)
for file in files:
if file.endswith('.xlsx'):
df = pd.read_excel(os.path.join(folder,file), header = None, skiprows=[0,1])
files
And it indeed shows three excel files:
Out[33] ['test_3d.xlsx', 'test_3d1.xlsx', 'test_3d2.xlsx']
But if I want to read the data in, for example, test_3d.xlsx, I used
test_3d.xlsx
or
print(text_3d)
I got
NameError: name 'test_3d' is not defined
I can only get the last one, i.e., test_3d2, by
print(df)
My question is how to get the data of the other two .xlsx files?
Thanks!
