I have a folder with 50 csv files like countrieslist1.csv,countrieslist2.csv, countrieslist3.csv and so on. I have a code where I can read the values from a csv file using pandas and plot the required graph from the data .What I want is that my code should take the first csv file ,do the plotting and save it as png file then it should take second csv file do the same and like this for every csv file so that in the end I should have 50 png file(one for each csv file)
I tried
import pandas as pd
import os
import matplotlib.pyplot as plt
folder_path = "C:/Users/xyz/Desktop/Countrieslist"
df=pd.read_csv(folder_path)
X=df.'columnname'.value_counts.(normalize=True).head(5)
X.plot.barh()
plt.ylabel()
plt.xlabel()
plt.title()
plt.savefig(folder_path[:-3]+'png')
This gives the output but it only for a single csv file.But I want a code that should take all csv files one by one, do the plotting and save it as png file.How can I do that?