Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
  • Loading branch information
davrot authored Dec 2, 2023
1 parent e1e98a2 commit c837e25
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions glob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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']
```

0 comments on commit c837e25

Please sign in to comment.