Skip to content

Commit

Permalink
configurable reltype key
Browse files Browse the repository at this point in the history
  • Loading branch information
mpreusse committed Jun 2, 2023
1 parent b1f3a01 commit a845f01
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions graphio/objects/relationshipset.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def to_csv_json_set(self, csv_file_path, json_file_path, write_mode: str = 'w'):
json.dump(self.metadata_dict, f)

@classmethod
def from_csv_json_set(cls, csv_file_path, json_file_path, load_items: bool = False):
def from_csv_json_set(cls, csv_file_path, json_file_path, load_items: bool = False, reltype_key=None):
"""
Read the default CSV/JSON file combination.
Expand All @@ -293,6 +293,9 @@ def from_csv_json_set(cls, csv_file_path, json_file_path, load_items: bool = Fal
:param load_items: Yield items from file (False, default) or load them to memory (True).
:return: The RelationshipSet.
"""
if not reltype_key:
reltype_key = 'rel_type'

with open(json_file_path) as f:
metadata = json.load(f)

Expand All @@ -311,7 +314,7 @@ def from_csv_json_set(cls, csv_file_path, json_file_path, load_items: bool = Fal
end_node_type_conversion = metadata.get('end_node_type_conversion', None)

# RelationshipSet instance
rs = cls(metadata['rel_type'],
rs = cls(metadata[reltype_key],
metadata['start_node_labels'],
metadata['end_node_labels'],
remove_prefix_from_keys(metadata['start_node_properties']),
Expand Down

0 comments on commit a845f01

Please sign in to comment.