简体   繁体   English

Python 脚本循环和搜索具有txt文件的目录文件夹中的单元格值(A2:A1700 - In xlsx)并将文件名保存在.txt或.csv文件中

[英]Python Script to Loop and Search cell values (A2:A1700 - In xlsx) in directory folder having txt files and Save file names in .txt or .csv files

I am new in scripting and currently working on project which requires me to read excel file having string from Cells A2 to A1700 in Sheet called "Index".我是脚本新手,目前正在从事一个项目,该项目需要我阅读 excel 文件,其中包含名为“索引”的工作表中从单元格 A2 到 A1700 的字符串。 I am trying to develop efficient python script to search each cell value from A2 to A1700 in "Index" Sheet against many text files in folder D:\Search Folder.我正在尝试开发高效的 python 脚本,以针对文件夹 D:\Search 文件夹中的许多文本文件搜索“索引”表中从 A2 到 A1700 的每个单元格值。 If cell value is found in certain text files, file names has to be saved in new text file with file name same as cell Value in folder D:\Result Folder.如果在某些文本文件中找到单元格值,则必须将文件名保存在新的文本文件中,文件名与文件夹 D:\Result 文件夹中的单元格值相同。 So far i got the script to search string in text file however i do not have any idea about how to work with excel files.到目前为止,我得到了在文本文件中搜索字符串的脚本,但是我不知道如何使用 excel 文件。

Search for string within files of a directory 在目录的文件中搜索字符串

Thanks Jignesh谢谢Jignesh

You can use pandas to read excel files with something like ( pd.read_excel ).您可以使用 pandas 来读取 excel 文件,例如( pd.read_excel )。 Then you can sompare those strings with the files in your Search Folder然后您可以将这些字符串与您的搜索文件夹中的文件进行比较

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM