Help with Python script
Dear all,
I am trying to use a program called phyphy. This program runs into python. I would like to create a script that can run in all my files. i. e., in the line e = Extractor("/path/to/FEL.json") the program uses a file in .json format but I have thousands of .json files. So, I want to create a script that can run for all the files that I have stored in several folders.
This is how I run the program into python but this is just for one file.
import phyphy
### Define a FEL Extractor, for example
e = Extractor("/path/to/FEL.json")
e.extract_csv("fel.csv") ## save to fel.csv
### tab-delimited output, as fel.tsv
e.extract_csv("fel.tsv", delim = "\t")
• 1,264 views
•
link
1 answer
import glob
files=[]
for folder in list-of-folders:
fnames=glob.glob(f'{folder}/*.json')
files+=fnames
for f in files:
your-scripts
• 0 views
•
link
Log in to answer this question.
Please format your code using the code formatting button:
Additionally, it's not clear what you have tried or what in particular you're having trouble with. Looping through files or running a script on many files is fairly straightforward, and there are many, many tutorials on how to do so that can be found with minimal searching.