Python - Cut all words between two Strings -
could me cut strings between join , on keyword in addition first line using python 3?
input data assigned variable
input_txt= date_dim date_dim_all inner join main_fact_response on (date_dim_all.response_date = main_fact_response.response_date) left join dim_fore_main on (dim_fore_main.id = fact_fore_respond.id) left join fact_fore_resi on (fact_fore_resi.fore_re = fact_fore_respond.fore_re inner join fact_fore_respond fact_fore_respond_merit on ( fact_fore_respond_merit.fore_respond = fact_fore_r espond.fore_respond
output data
date_dim date_dim_all, main_fact_response, dim_fore_main, fact_fore_resi, fact_fore_respond fact_fore_respond_merit
input_data = '''date_dim date_dim_all inner join main_fact_response on (date_dim_all.response_date = main_fact_response.response_date) left join dim_fore_main on (dim_fore_main.id = fact_fore_respond.id) left join fact_fore_resi on (fact_fore_resi.fore_re = fact_fore_respond.fore_re inner join fact_fore_respond fact_fore_respond_merit on ( fact_fore_respond_merit.fore_respond = fact_fore_r espond.fore_respond''' input_data = input_data.replace("join","cuthere") input_data = input_data.replace("on","cuthere") data_list = input_data.split('cuthere') data_list = data_list[1::2] #the next part of code needed because string multiline . = 0 < len(data_list): data_list[i] = data_list[i].strip()
Comments
Post a Comment