Skip to content

Add data from CSV #15

@Supernova-45

Description

@Supernova-45

Would it be possible to add methods that allow you to input a CSV file exported from Edge (rather than a JSON) to GraphClient? Something like this:

def add_nodes_from_csv(csv_file, graph):
    with open(csv_file, 'r') as file:
        reader = csv.DictReader(file)
        for row in reader:
            node_id = UUID(row['id'])
            label = row['label']
            properties = {
                'url': row['url'],
                'color_red': int(row['color_red']),
                'color_green': int(row['color_green']),
                'color_blue': int(row['color_blue']),
                'size': int(row['size'])
            }
            graph.create_node(label=label, id=node_id, **properties)

def add_edges_from_csv(csv_file, graph):
    with open(csv_file, 'r') as file):
        reader = csv.DictReader(file)
        for row in reader:
            from_id = UUID(row['from'])
            to_id = UUID(row['to'])
            weight = float(row['weight'])
            graph.create_edge(from_id, to_id, weight)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions