Shorouk Adel
Shorouk Adel

Reputation: 157

Getting empty list when using glob.glob in python to return paths from pc

I use jupyter notebook anaconda, I need to read paths of specific files from folder

paths = glob.glob('E:\master\neural network\mit-bih-arrhythmia-database-1.0.0/*.atr', recursive=True)
paths = glob.glob('E:\master\neural network\mit-bih-arrhythmia-database-1.0.0/*.atr')
**paths = glob.glob('E:\master\neural network\mit-bih-arrhythmia-database-1.0.0\*.atr')**

I try these lines but paths returns empty

Upvotes: 0

Views: 253

Answers (1)

Red
Red

Reputation: 27567

You need double backslashes because they're special characters:

paths = glob.glob('E:\\master\\neural network\\mit-bih-arrhythmia-database-1.0.0\\*.atr', recursive=True)

You can also use an r string instead, so that all the characters will be interpreted as normal:

paths = glob.glob(r'E:\master\neural network\mit-bih-arrhythmia-database-1.0.0\*.atr', recursive=True)

Upvotes: 1

Related Questions