-1

How can I read a file that ends with csv in a certain path?

import pandas as pd

df = pd.read_csv('C:\Users\*.csv')

Thanks

lolo
  • 646
  • 2
  • 7
  • 19
  • I think you can find an answer at [this link](https://stackoverflow.com/questions/5013532/open-file-by-filename-wildcard) – Luc Blassel Jan 18 '19 at 15:22
  • What issue are you having? Maybe I'm not clear on what your question is. That would be a valid function to use. – busybear Jan 18 '19 at 15:23

1 Answers1

2

There are multiple ways of doing it. Here is my answer.Use glob module and make a for/while loop of all the files.

import glob

listcsv=glob.glob('C:\Users\*.csv')
for i in listcsv:
    df=pd.read_csv(i)