I have a text file that contains many path file.txt files:
C:\data\AS\WO\AS_WOP_1PPPPPP20070506.bin C:\data\AS\WO\AS_WOP_1PPPPPP20070606.bin C:\data\AS\WO\AS_WOP_1PPPPPP20070708.bin C:\data\AS\WO\AS_WOP_1PPPPPP20070808.bin ...
What I did with Regex to extract the date from the path:
import re textfile = open('file.txt', 'r') filetext = textfile.read() textfile.close() data = [] for line in filetext: matches = re.search("AS_[AZ]{3}_(.{7})([0-9]{4})([0-9]{2})([0-9]{2})", line) data.append(line)
he does not give what I want.
My output should look like this:
year month 2007 05 2007 06 2007 07 2007 08
and then save it as a list of lists :
[['2007', '5'], ['2007', '6'], ['2007', '7'], ['2007', '8']]
or save it as pandas .
is there any way with regex to get what i want!
source share