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:28:44 +01:00 committed by GitHub
parent e1e98a2a5a
commit c837e25203
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,3 +95,19 @@ Testfile_2
Testfile_3
Testfile_10
```
Alternatively without a for-loop but using [map](https://docs.python.org/3/library/functions.html#map) , [list](https://docs.python.org/3/library/functions.html#func-list) and [lambda functions](https://docs.python.org/3/reference/expressions.html#lambda):
```python
import glob
from natsort import natsorted
filenames = natsorted(glob.glob("*.mat"))
filenames = list(map(lambda s: s.rsplit(".", 1)[0], filenames))
print(filenames)
```
```python console
['Testfile_1', 'Testfile_2', 'Testfile_3', 'Testfile_10']
```