-2

I am having a problems getting over this hurdle.

I have tried several ways to add a wildcard "*" in the files name but having no luck. I am trying to add the wildcard in the date section of the file name but it is not working for me.

Solex_29122020.xlsx Road_29122020.xlsx Cross_29122020.xlsx

I am trying to automate a process and the only changing part of the file is the date so I thought using a wild card will solve the issue but I dont know where the wild card would go. I tried the below and still no luck.

Solex_*.xlsx

Road_*.xlsx

Cross_*.xlsx

Any help will be appreciated

jan80808
  • 9
  • 2
  • 4
    Add a wildcard where? When looking for the files? How are you opening/looking for the files? We can't really help without knowing what you're actually trying to do. You need to post some code here, ideally a [mre]. Have you looked up any other existing answers? Does [this](https://stackoverflow.com/questions/3348753/search-for-a-file-using-a-wildcard) help? – Random Davis Dec 29 '20 at 18:48
  • 2
    Please share snippets of code you have written for this – Ananth Dec 29 '20 at 18:50
  • 1
    @jan80808 As the others before me have mentioned, we can't help much without knowing what you're trying to do, but [the `glob` module](https://docs.python.org/3/library/glob.html) may be of interest to you here. – Ben Soyka Dec 29 '20 at 18:51

1 Answers1

0

You are probably looking for https://docs.python.org/3/library/glob.html

example:

import glob
for filename in glob.glob('Solex_*.xlsx'):
  print(filename)
Tiago Carreira
  • 1,476
  • 1
  • 11
  • 15