Untitled

 avatar
unknown
plain_text
2 years ago
1.6 kB
5
Indexable
# ...

for _, row in filtered_df.iterrows():
    eprm_table_name = row['eprm_table_name']
    eprm_join_cols_entity = row['eprm_join_cols_entity']
    eprm_join_cols_reim = row['eprm_join_cols_reim']
    eprm_table_alias = row['eprm_table_alias']

    # Split the strings by ',' to get individual column assignments
    columns_entity = eprm_join_cols_entity.split(',') if eprm_join_cols_entity else []
    columns_reim = eprm_join_cols_reim.split(',') if eprm_join_cols_reim else []

    # Compare the lengths of the column assignments
    if len(columns_entity) != len(columns_reim):
        # If entity columns are fewer, append missing columns to the end of columns_reim
        if len(columns_entity) < len(columns_reim):
            columns_entity += columns_reim[len(columns_entity):]
        # If entity columns are more, append missing columns to the end of columns_entity
        else:
            columns_reim += columns_entity[len(columns_reim):]

    # Construct the modified assignment string
    assignment_string = ''
    for col_entity, col_reim in zip(columns_entity, columns_reim):
        # Extract the column name after '='
        col_name_entity = col_entity.split('=')[0].strip()
        col_name_reim = col_reim.split('=')[0].strip()
        # Append the modified assignment to the string
        assignment_string += f"{col_reim.replace(col_name_reim, eprm_table_alias + '.' + col_name_entity)}, "

    # Remove the trailing comma and whitespace
    assignment_string = assignment_string.rstrip(', ')
    assignment_string = assignment_string.replace("AND", ",")
    eprm_join_reim = assignment_string

    # ...
Editor is loading...