Update README.md

Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
David Rotermund 2023-12-02 02:22:18 +01:00 committed by GitHub
parent 3ee1e389a0
commit e1e98a2a5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,3 +77,21 @@ print(list)
['Testfile_1.mat', 'Testfile_2.mat', 'Testfile_3.mat', 'Testfile_10.mat']
```
## rsplit
And maybe you don't want to have the file extensions. Then we can use [rsplit](https://docs.python.org/3/library/stdtypes.html#str.rsplit) on the string.
```python
import glob
from natsort import natsorted
for filename in natsorted(glob.glob("*.mat")):
print(filename.rsplit(".", 1)[0])
```
```python console
Testfile_1
Testfile_2
Testfile_3
Testfile_10
```