Linked Questions

171 votes
13 answers
353k views

I want to open a series of subfolders in a folder and find some text files and print some lines of the text files. I am using this: configfiles = glob.glob('C:/Users/sam/Desktop/file1/*.txt') But ...
UserYmY's user avatar
  • 8,654
-1 votes
3 answers
508 views

So I wrote a Python scrip that would do a certain thing to a certain .txt file: with open("1.txt") as f: for line in f: #DoStuff Now this works for 1 .txt file. I have One master folder, ...
Jeries Haddad's user avatar
0 votes
1 answer
376 views

Here is an example of my directory: Auto ├── Test │ └── Test.csv ├── Test2 │ └── Test2.csv └── new.csv I am trying to read all the csv files in the directory. Here is my code: import glob, os os....
GooseCake's user avatar
0 votes
1 answer
223 views

I have following directory structure $ find . ./file1.html ./soquest_glob.py ./dir1 ./dir1/file2.html ./dir2 ./dir2/file3.html (I have added blank lines above to clarify files in different folders)....
rnso's user avatar
  • 24.7k
-1 votes
1 answer
385 views

I am new to the programing world and I have hit a snag on a piece of code. What I have: I have a piece of code that identifies all .MP4 files and calculates the size of the files within a directory. ...
sungliengk's user avatar
0 votes
0 answers
264 views

I'm iterating through a directory containing a number of JSON files and sub-directories and .txt files. I need to do this until there are no more JSON files remaining in this root directory. How do ...
entity without identity's user avatar
0 votes
0 answers
199 views

I have a directory set up like this: content/ content/file1-helloworld.txt content/file2myproject.txt content/file3_howareyou.txt And in python I have the following: file = open("content/FILE_NAME....
max - maauer's user avatar
1 vote
0 answers
170 views

Still new to python so please dont mind the noob question.I have spend some time first researching and trying to figure it out.I have a files that are in directories.The files look like this; A_1_BB_Z....
Kamikaze K's user avatar
3 votes
0 answers
161 views

with open('C:/Users/JDoe/Downloads/rows_to_del.txt', 'r', encoding="utf8") as f: delete_docs = [line.rstrip('\n') for line in f] print(delete_docs) def txtUpdater(): path = "C:/Users/JDoe/Downloads/...
sherrific's user avatar
-2 votes
1 answer
41 views

I'm making a bit of a stupid program that's supposed to look like a basic operating system in python, except it's just some fancy fake words while it "boots up", then some basic ...
Aaron Jha's user avatar
0 votes
1 answer
41 views

So I got this working, but now I would like some help to make it read folders and subfolders Also how can I make this change multiple files at one time This is what I got going import glob import ...
JR Santos's user avatar
  • 145
1010 votes
36 answers
1.7m views

Is there a way to return a list of all the subdirectories in the current directory in Python? I know you can do this with files, but I need to get the list of directories instead.
Brad Zeis's user avatar
  • 10.9k
205 votes
7 answers
144k views

How can I use pathlib to recursively iterate over all subdirectories of a given directory? p = Path('docs') for child in p.iterdir(): # do things with child only seems to iterate over the ...
Oblomov's user avatar
  • 9,735
199 votes
4 answers
159k views

I've tried the following command but I don't understand the results: ls ** What does ** mean? How should I use it?
Mike Blair's user avatar
  • 2,121
102 votes
5 answers
109k views

I wanted to know what is the pythonic function for this : I want to remove everything before the wa path. p = path.split('/') counter = 0 while True: if p[counter] == 'wa': break ...
Natim's user avatar
  • 18.2k

15 30 50 per page
1
2 3 4 5
7