def apply_schema(df, blobNamePath : str): try: global schemas_list found = False schema = pd.DataFrame() i=0 idx = -1 for schema_item in schemas_list: if schema_item["path_item"] in blobNamePath: found = True schema_path = blobNamePath.split(schema_item["path_item"])[0] schema_path = schema_path + 'schemas/' + schema_item["path_item"] + schema_item["file_name"] if "schema" in schema_item.keys(): schema = schema_item["schema"] else: idx=i i=i+1 if found == True: if schema.empty == True: schema = getBlob(schema_path,"schema_filename.csv") schemas_list[idx]["schema"] = schema if schema.empty == False: schema_cols = schema.columns for col in schema_cols: if col not in df.columns: df[col]='' df = df[schema_cols] return df except Exception as e: print('****** error applying schema' + e.message) raise e