Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

python - How to generate graph for data in a specific file, present in each subfolder?

I have sub-folders containing files with same name. Each file has data in it, I want to plot graph for a specific file which is present in every sub-folder. I should have graph generated for each sub-folder. The data contains multiple variable so looking for code which can generate the graph for a specific variables in it.

As of now I am able to create a list of the files for which I want to plot graph for, generating multiple DataFrames for each file and then plotting the graph by providing variable name seems the best approach but I am not able to generate DataFrame for each file in the code.

The following code shows single DataFrame, I want to have DataFrames for each of the files so that I can plot individual graphs.

Following is the code for creating the list of files:

import os
from glob import glob
PATH = "C:/Users/skalode/Desktop/2D Post"
EXT = "thermo_region0.out"
all_files = [file
                 for path, subdir, files in os.walk(PATH)
                 for file in glob(os.path.join(path, EXT))]
for file in all_files:
    df=pd.read_fwf(file, skiprows=[0,1,3,4])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...