My Directory
looks like this:
P1_SAMPLE.csv
P2_SAMPLE.csv
P3_SAMPLE.csv
P11_SAMPLE.csv
P12_SAMPLE.csv
P13_SAMPLE.csv
My code looks like this:
from pathlib import Path
file_path = r'C:\Users\HP\Desktop\My Directory'
for fle in Path(file_path).glob('P*_SAMPLE.csv'):
number = fle.name[1]
print(number)
This gives output:
1
2
3
1
1
1
How do I make the code output the actual full digits for each file, like this:
1
2
3
11
12
13
Would prefer to use fle.name[]
if possible. Many thanks in advance!