Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何读取位置最新且名称中包含特定单词的excel文件_Python_Excel_Pandas - Fatal编程技术网

Python 如何读取位置最新且名称中包含特定单词的excel文件

Python 如何读取位置最新且名称中包含特定单词的excel文件,python,excel,pandas,Python,Excel,Pandas,我想读取位置文件夹/目录中最新的excel文件,该文件的名称中包含特定单词。 例如,目录包含以下文件: file_apple_1jan.xlsx file_apple_2jan.xlsx file_apple_13jan.xlsx file_mango_23jan.xlsx 我想从目录中读取名称为apple的最新excel文件,即file_apple_13jan.xlsx,无需明确指定优先使用pandas。 注意:为了方便起见,我在这里使用了与创建日期一致的文件名。我怀疑是否有人会为您编写代码

我想读取位置文件夹/目录中最新的excel文件,该文件的名称中包含特定单词。 例如,目录包含以下文件:

file_apple_1jan.xlsx
file_apple_2jan.xlsx
file_apple_13jan.xlsx
file_mango_23jan.xlsx
我想从目录中读取名称为apple的最新excel文件,即file_apple_13jan.xlsx,无需明确指定优先使用pandas。
注意:为了方便起见,我在这里使用了与创建日期一致的文件名。

我怀疑是否有人会为您编写代码,但从这里开始,您可以了解如何编写代码

获取目录中的所有文件名 过滤掉那些没有你的关键字的 使用os.path.getmtimepath对它们进行比较,以获取上次修改的日期 选择具有最近一次修改日期的日期
最近在这里的vba中有一个类似的问题-值得查找。您没有提到“类似的问题”。你能在SolarMike上做吗