-1

I am trying to open a file with python where the filename is 2018_01_25_(filename).csv.

In batch files i used C:*.csv to open the csv file. I have tried this in python 2.7 but it doesnt work.

a = pd.read_csv("filename.csv") i want to use, a = pd.read_csv("*.csv") Is there a python equivalent to this?

1 Answers1

0

As far as I know there isn't a one-liner for this, but you can get around it with the os package.

 import os
 for f in os.scandir():
      if '.csv' == f[-4:]:
           a = pd.read_csv(f)
           break

This code will read the first .csv file into a.

Polkaguy6000
  • 1,150
  • 1
  • 8
  • 15