Skip to content

Tag: os.walk

print/list only 5 entries from OS.Walk in python

My Goal – To list only 5 entries when using OS walk. So far I have only been able to get a list of everything that I find using OS.Walk or only list one entry. (By using the return function) My code: import os import subprocess The Results: If there is any way to only show 5 instead of the

Check the presence of files within directory

under “mypath” i have one folder and under this folder i have files and i want to check the existance of files under this folder, but in my example below it checks only the directory where is the folder (where there is no files) , So any idea? Answer You need to check the right directory: Like @td…

How to modify specific line in sql file?

I am trying to modify a line in sql file in a directory. Currently have written the code which navigates to files directory according to user input . each sql file in that dir has these 2 lines: I am trying to do is loop through all files and I want to change-set every-time the script runs. so those 2