could anyone advise me how to apply this code to several csv in one folder? Then, save the modified csv to another folder and each separately? In short, I need to automate it.

I need to automatically load the csv file, execute the code, save the newly modified csv file, and then repeat it to the next csv file in the folder.

```
import pandas as pd
import datetime as dt
import numpy as np
from numpy import nan as Nan

path = "C://Users//Zemi4//Desktop//csv//A-001.csv"

df = pd.read_csv(path,delimiter=";")

df['ta'] = pd.to_numeric(df['ta'])
df['tw'] = pd.to_numeric(df['tw'])

df["time_str"] = [dt.datetime.strptime(d, "%d.%m.%Y %H:%M:%S") for d in df["time"]]
df["time_str"] = [d.date() for d in df["time_str"]]
df["time_str"] = pd.to_datetime(df["time_str"])
df["time_zaokrouhleny"]=df["time_str"]

def analyza(pozadovane_data):

    new_list = []

    new_df = pd.DataFrame(new_list)

    new_df=df.loc[df["time_str"] == pozadovane_data,["ta","tw", "zone", "time_zaokrouhleny"]]

    counter = new_df.ta.count()

    if counter < 24:
        for i in range(counter,24):
            new_df.loc[i] = [Nan for n in range(4)]
            new_df["ta"]= new_df.ta.fillna(0)
            new_df["tw"] = new_df.tw.fillna(0)
            new_df["zone"] = new_df.zone.fillna(0)
            new_df["time_zaokrouhleny"]=new_df.time_zaokrouhleny.fillna(new_df.time_zaokrouhleny.min())

    elif counter > 24:
        counter_list = list(range(24,counter))
        new_df = new_df.drop(new_df.index[counter_list])

    new_df["time_oprava"] = [dt.datetime.combine(d.date(),dt.time(1,0)) for d in new_df["time_zaokrouhleny"]]

    s = 0
    cas_list = []

    for d in new_df["time_oprava"]:
        d =d + dt.timedelta(hours=s)
        #print(d)
        #print(s)
        cas_list.append(d)
        s = s + 1

    se = pd.Series(cas_list)

    new_df['time_oprava'] = se.values

    new_df['Validace'] = (new_df['ta'] != 0) & (new_df['tw'] != 0)

    new_df['Rozdil'] = new_df['ta'] - new_df['tw']

    new_df.rename(columns={"ta": "Skutecna teplota", "tw": "Pozadovana teplota", "time_oprava": "Cas", "zone": "Mistnost"}, inplace = True)

    new_df.index = new_df['Cas']

    return new_df

start = dt.datetime(2010,10,6)
end = dt.datetime(2010,12,27)

date_range = []
date_range = [start + dt.timedelta(days=x) for x in range(0,(end-start).days)]

new_list = []

vysledek_df =pd.DataFrame(new_list)

for d in date_range:
    pom = analyza(d)
    vysledek_df = vysledek_df.append(pom,ignore_index=True)
    vysledek_df.pop('time_zaokrouhleny')
    vysledek_df.to_csv('C://Users//Zemi4//Desktop//zpr//A-001.csv', encoding='utf-8', index=False)

```

The code itself works correctly. Thank you for your advice.