2021年3月31日星期三

How to process multiple files in a loop?

I'm trying to create a loop that searches the current directory for all .txt files and then adds the data in those files to a dictionary. Up until now, I've only needed to open one file at a time so I'm not entirely sure how this would be done. Can I use regex to match file types and open them that way?

Edit: The data I'm supposed to parse with Regex is a bunch of websites with pageview counts. I'm to build a dictionary using the page_title as the key, with the sum of count_views to that page as the value. There are other requirements for the assignment but they're just different ways of sorting and displaying the data I've collected from my original question.

TLDR- I need to make one dictionary from multiple files of data and be able to sort and display the contents of the dictionary

https://stackoverflow.com/questions/66896580/how-to-process-multiple-files-in-a-loop April 01, 2021 at 07:32AM

没有评论:

发表评论