1

I have multiple csv files in format 'name' + 'date', eg 'data 2020-07-01.csv'. I am able to read multiple csv files with glob as in:

all_files = glob.glob(path + "*.csv")
df = pd.concat([pd.read_csv(f) for f in all_files], ignore_index = True)

But what I want to be able to do is add a column containing the date part of the file name string when doing the multi file read. How do I do that?

Thanks

2
  • Does this answer your question? Python Pandas add Filename Column CSV Commented Jul 22, 2020 at 16:29
  • Sorry late reply @MaxFeinberg. Yes it does. thanks Commented Nov 7, 2020 at 9:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.