This is possible with os
from the standard library and 3rd party library pandas
:
import os
import pandas as pd
mypath = os.path.join('Downloads', 'challenges')
# get list of files
files = [f for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f))]
# build list of dataframes, adding "challenge" column
dfs = [pd.read_csv(os.path.join(mypath, f)).assign(challenge=f) for f in files]
# concatenate dataframes into one
df = pd.concat(dfs, ignore_index=True)
# write to csv
df.to_csv('all_entrants.csv')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…