FileNotFoundError: [Errno 2] No such file or directory: 'Results/time_redact.csv'
时间: 2023-08-19 21:14:48 浏览: 162
result.csv
引用\[1\]:遇到问题: FileNotFoundError: \[Errno 2\] No such file or directory: 'models/trained_models/wind_model_NL_1h_CNN2DWind_NL.pt' 。 引用\[2\]:报错代码 #FileNotFoundError: \[Errno 2\] No such file or directory: './data/articles.csv' aaa = pd.read_csv('./data/articles.csv') # ./data表示该目录下有个data文件,实际data是在code文件的上一层文件中 aaa 。 引用\[3\]:** 代码如下 import csv import os import pandas as pd # 先创建一个空列表,然后通过for循环实现 readList = \[\] files = os.listdir(r"D:\Lynn.Yan\Python\Plot\data") # i是文件 # 读取多个csv文件内容 # 跳过第一行“标题” # 添加“文件名”作为新的列 for i in files: with open('{}'.format(i), 'r') as read_csvfile: read_all = csv.reader(read_csvfile) next(read_csvfile) for line in read_all: line.append(i) readList.append(line) # list转化成dataframe # 添加列名 testData = pd.DataFrame(readList) titleList = \["Cycle", "Voltage", "Current", "RPM", "Torque", "Force", "Position", "CustomAI", "TC1", "TC2", "TC3", "TC4", "TC5", "UpdateTime", "Filename"\] testData.columns = titleList testData.head() 。 问题:FileNotFoundError: \[Errno 2\] No such file or directory: 'Results/time_redact.csv'
回答: 这个错误是由于文件或目录不存在导致的。在你的代码中,你尝试读取了一个名为'models/trained_models/wind_model_NL_1h_CNN2DWind_NL.pt'的文件,但是该文件不存在。同样地,在另一个代码段中,你尝试读取了一个名为'./data/articles.csv'的文件,但是该文件也不存在。最后,你还尝试读取了一个名为'Results/time_redact.csv'的文件,同样地,该文件也不存在。请确保你提供的文件路径是正确的,并且文件确实存在于指定的位置。
#### 引用[.reference_title]
- *1* [FileNotFoundError: [Errno 2] No such file or directory: ‘models/trained_models/wind_model_NL_1h_CNN...](https://blog.csdn.net/lcnana/article/details/121307592)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [FileNotFoundError: [Errno 2] No such file or directory: ‘./data/articles.csv](https://blog.csdn.net/weixin_43409127/article/details/124175494)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [解决FileNotFoundError: [Errno 2] No such file or directory: ‘220102933.86_56.csv](https://blog.csdn.net/weixin_45560266/article/details/126460377)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文