I have 2 lists, one with jobs and one with data.
jobs = [
'P01_TEST1_C',
'P01_TEST3_B',
'P01_TEST5_F',
'P01_QUALITY_C'
]
data = [
['JOB','X01_TEST1_C', 'NAME', 'DATE', 'EXTRADATA'],
['JOB','P01_TEST3_C', 'NAME', 'DATE', 'EXTRADATA'],
['JOB','X01_TEST1002_C', 'NAME', 'DATE', 'EXTRADATA'],
['JOB','X01_TEST4231_C', 'NAME', 'DATE', 'EXTRAP01_TEST5_FDATA']
]
I want to find the lines in data that have jobs. The first 3 characters in jobs don't matter so
answer I want would be =
['JOB','X01_TEST1_C', 'NAME', 'DATE', 'EXTRADATA'] #matching on P01_TEST1_C
['JOB','P01_TEST3_B', 'NAME', 'DATE', 'EXTRADATA'] # matching on P01_TEST3_B
['JOB','X01_TEST4231_C', 'NAME', 'DATE', 'EXTRAP01_TEST5_FDATA']] #matching on the P01_TEST5_F in between the EXTRADATA
If I use the below it matches if I make it exact but wouldn't find the name within the EXTRADATA
jobs = ['X01_TEST1_C','P01_TEST3_B C']
newest = [s for s in rows if any(rows in s for rows in jobs)]
but what I think I want to do is search data for
['_TEST1_C', '_TEST3_B', '_TEST5_F', '_QUALITY_C']
but with * wildcards
( I have removed the front part with
for i in jobs:
i = i[3:]
)
Any help greatly appreciated Thanks