I am trying to loop through an array that has the excel file name and then use that to read that excel using pandas read_excel. However i am unable to pass the path to read_excel(). Below is how my code looks.
import pandas as pd
from pathlib import Path
Moviedb = []
file_Name = ["/SG_JW_09-02-2020_1900_2009", "/SG_JW_09-02-2020_2010_2015", "/SG_JW_09-02-2020_2016_2017", "/SG_JW_09-02-2020_2018_2020", "/SG_JW_09-02-2020_2018_2020_1", "/SG_JW_09-02-2020_2018_2020_2"]
filecnt = 0
cnt = 0
for filename in file_Name:
p = Path("D:/Python scripts/SG Title/SG/JW/03_02_2020" + filename)
df = pd.read_excel(p)
filecnt = filecnt + 1
I get the below error when i run this.
Can someone help me with this?
路径("D:/Python scripts/SG Title/SG/JW/03_02_2020" + 文件名 + ".xlsx")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.