def _expand_properties(g: GraphTraversalSource, column: str, value: Any) -> GraphTraversalSource: # If this is a list then expand it out into multiple property calls if isinstance(value, list) and len(value) > 0: for item in value: g = g.property(Cardinality.set_, column, item) elif pd.notna(value): g = g.property(Cardinality.set_, column, value) return g
def _build_gremlin_properties(g: GraphTraversalSource, row: Any) -> GraphTraversalSource: for (column, value) in row.items(): if column not in ["~id", "~label", "~to", "~from"]: if isinstance(value, list) and len(value) > 0: for item in value: g = g.property(Cardinality.set_, column, item) elif not pd.isna(value) and not pd.isnull(value): g = g.property(column, value) return g
def _set_properties(g: GraphTraversalSource, use_header_cardinality: bool, row: Any) -> GraphTraversalSource: for (column, value) in row.items(): if column not in ["~id", "~label", "~to", "~from"]: # If the column header is specifying the cardinality then use it if use_header_cardinality: if column.lower().find("(single)") > 0 and pd.notna(value): g = g.property(Cardinality.single, _get_column_name(column), value) else: g = _expand_properties(g, _get_column_name(column), value) else: # If not using header cardinality then use the default of set g = _expand_properties(g, column, value) return g