我有一个具有特定路径的文件夹,我想浏览该文件夹中的所有文件夹。每个子文件夹包含多个文件,我只需要一个特定的“ .csv”文件。我成功读取了不同的文件夹并选择了正确的文件,但是当我尝试打开它(带有熊猫和numpy的位)时,出现IOError,指出相应的文件不存在。
import pandas as pd
import numpy as np
path = "some_path"
data_list = os.listdir(path)
array = []
for file in data_list:
if file.endswith("name_requirement"):
array.append(function(file))
file_filter = "second_name_requirement"
def function(second_path):
file_list = os.listdir(path + "\\" + str(second_path))
average = 0
for file in file_list:
if str(file)[-20:-4] == file_filter:
measurements = pd.read_csv(file, delimiter = ";", skiprows = 1, usecols = [1])
# measurements = np.loadtxt(file, delimiter =";", skiprows =1)
.....
`