简体   繁体   English

遍历 python pandas 中的许多 CSV 文件

[英]Iterating through many CSV files in python pandas

I have many CSV files that are my datapoint files, they are different combinations of my test subjects.我有许多 CSV 文件是我的数据点文件,它们是我的测试对象的不同组合。 在此处输入图像描述

I have some code that runs one CSV at a time, but I have to comment/uncomment when I want my code the analyse the next CSV.我有一些代码一次运行一个 CSV,但是当我希望我的代码分析下一个 CSV 时,我必须注释/取消注释。

Is there any good looping techniques that I can apply such that the processing/iteration is automatic for all my CSVs?有没有什么好的循环技术可以应用,这样我的所有 CSV 的处理/迭代都是自动的?

Thank you谢谢

Yes, create list of filenames and then loop by it:是的,创建文件名列表,然后循环:

files = ['BenNIC O.csv','BenQQ O.csv']

for file in files:
     df = pd.read_csv(file)
     #processing

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

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