I am trying to read a csv file in Pandas. I am automating the script to daily read the data from csv and execute. Daily a new csv is added in the folder where i have the csv files. Newly added csv file have the same name format except the date part in it changes daily and month part change monthly. Year would change yearly. How can i automate to read the csv files daily with its name changing continuously?
Example: If the name for yesterday`s file is:
Name_29Mar2020_data_by_company.csv
Tomorrow`s file will be:
Name_30Mar2020_data_by_company.csv
You can use the datetime module:
import pandas as pd
from datetime import datetime
fname = datetime.today().strftime('Name_%d%b%Y_data_by_company.csv')
df = pd.read_csv(fname)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With