How to use glob to read only a limited set of files?
I have json files with numbers from 50 to 20,000 (e.g. 50.json, 51.json, 52.json ... 19999.json, 20000.json) in the same directory. I want to read only files with numbers from 15000 to 18000.
For this, I use glob as shown below, but it generates an empty list every time I try to filter out the numbers. I tried my best to follow this link ( https://docs.python.org/2/library/glob.html ), but I'm not sure what I'm doing wrong.
>>> directory = "/Users/Chris/Dropbox"
>>> read_files = glob.glob(directory+"/[15000-18000].*")
>>> print read_files
[]
Also, what if I need files with any number greater than 18000?
Chris source
share