I have a bunch of .json files in a folder which follow a the pattern file00.json, file01.json, etc. I tried to iterate the below code for all the .json files. But it is not working. So I am manually doing this for each file. Any help here is appreciated.
    for filename in os.listdir(os.getcwd()):  
    root, ext = os.path.splitext(filename)  
    if ext == '.json':  
        with open('file-00.json') as json_file:
            data = json.load(json_file)
            header = ['Pair', 'Rank', 'Suite'] 
        with open("file-00.csv", 'w') as file:
            dw = csv.DictWriter(file, delimiter=',',fieldnames=header)
            dw.writeheader()
        with open('batch-00.csv', 'a', newline= '') as f:
            for i in data:
                data1 = [i, i[:-1], i[-1]]
                write = csv.writer(f)
                write.writerow(data1)
                print(data1)
# reading the csv file
df = pd.read_csv("file-00.csv")
df
  
#updating the column value/data
df['Rank'] = df['Rank'].replace({'K': '10'})
df['Rank'] = df['Rank'].replace({'Q': '10'})
df['Rank'] = df['Rank'].replace({'J': '10'})
df['Rank'] = df['Rank'].replace({'A': '1'})
df
  
#writing into the file
df.to_csv("file-00.csv", index=False)
  
#print(df)
 
    