I have made a pandas data frame where I have two main columns, one with a job name the other with a SQL script.
I need to extract tables ending in '_REP', I have split the script into lists of the words (note the csv doesn't have commas for the script in it originally) and need to return the EXCTRATION and the actual tables that have '_REP' at the end, if there is no _REP table it should return noRepTable or something to indicate there is no _REP. The result needs to be a csv as well.
df = pd.read_csv("requests.csv")
df["sql_split"]= df["sql"].str.split(" ")
EXTRACTION ... sql_split
0 AU01 ... [SELECT, COLUMN1, AS, CONNECTION_ID, FROM, TABLE_REP]
1 AU04 ... [SELECT, COLUMN2, AS, EVENT_ACTION, FROM, TABLE2_REP]
2 AU05 ... [SELECT, COLUMN1, AS, ID, FROM, TABLE_DB]
expected result:
AU01,TABLE_REP
AU04,TABLE2_REP
AU05,noRepTable