Hello, I'm Python's beginner. I've been doing this and that by myself, but I don't know the answer, so I'm leaving a question.
The code is as follows.
import glob
list_filepath = glob.glob('/content/drive/MyDrive/Final Sheets_python/raw/901000_Sheet/*.ipynb')
for filepath in list_filepath:
print(filepath)
%cd /content/drive/MyDrive/Final Sheets_python/raw/901000_Sheet/
run 901000-1.ipynb
%cd /content/drive/MyDrive/Final Sheets_python/raw/901000_Sheet/
run 901000-2.ipynb
There are five files in the folder, 901000-1, 2, 3, 4, 5. Until now, every time I turned 5 files, I kept using the %cd command to move the path and run, but I thought it was a waste of time.
Is there a way to create a code that can repeat %cd and run in the order of the number of files in the folder? I searched with keywords such as path movement and for statement, but I don't know what information to use.
I ask for your advice.
Thank you for reading.
python loops
import subprocess
...
You can enter commands by using the subprocess library!
If you have any more questions, please let me know. :)
© 2024 OneMinuteCode. All rights reserved.