I'm trying to run my script on several .csv files and output the results from each file. A snippet of my code is as follows-
import sys
import os
import logging
import subprocess
import argparse
import pandas as pd
import glob
files = glob.glob('/scratch/*/*.csv')
for file in files:
df = pd.read_csv(file,delimiter = ',',skiprows=range(1,11))
#do some calculation on each file
#calculate the final value
metric = (max(max(dif_r1a),max(dif_r1c),max(dif_r1g),max(dif_r1t),max(dif_r2a),max(dif_r2c),max(dif_r2g),max(dif_r2t)))
#output the final value for each csv file
print(os.path.basename(file) + ' ' + str(metric))
The output I get is only for a single csv file
file1.csv 0.25
How do I iterate this to output the value for all the csv files ?
Thank you
forloop?