Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So, I need to write a script that lets the program look into each folder, into the .txt file, read a number, and store it into its memory. Also, I need it to loop so the script can run and look at multiple directories so it can find the number in the files. That way, with the numbers, I can make a bar graph.

What I have tried:

I tried directory = os.fsencode(my_directory_that_info_is_in)
for file in os.listdir()

#That's all I can do for now
Posted
Updated 17-Jun-17 20:35pm

1 solution

Well it is not at all clear what you cannot do. If you have the list of files in a directory then it should be easy to read each one in turn. You need to pass the directory name to os.listdir() in order to get the list. See 16.1. os — Miscellaneous operating system interfaces — Python 3.6.2rc1 documentation[^] .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900