Discussion Forum

Data Loading by Python Client

Hi
Can we load data from one CSV file to Grakn schema by using python client? if yes kindly tell me how?

Regards,

M Ameen

Hi - thanks for your question.

Yes, you can use the client to create create your data loader that is tailored to your use case. However, there is one solution that was built for Java - but could be used as a loader.

GraMi. You can find it here: https://github.com/bayer-science-for-a-better-life/grami

Let us know how it goes.

Hi, @daniel as I mentioned above we need to load data in a schema from one CSV file by using python client but " grami" is in java.
https://dev.grakn.ai/docs/examples/phone-calls-migration-python here you can see loaded data to “Phone_call” schema from four CSV files by making template functions. but we have only one CSV file it contains all the data of Entities and Relationships, so how we can load data to our schema from one file?

Hey, @mameen I’ve had issues trying to get CSV data into grakn as well. I have created a new python framework called Codex that will simplify the process.

You can clone the repo here https://github.com/banjtheman/grakn-codex

With codex all you would do is

import pandas as pd
from codex import CodexKg

# Init Codex 
codexkg = CodexKg()

# Connect to keyspace
codexkg.create_db("MY_KEYSPACE")

#load df
MY_CSV= pd.read_csv("my_data.csv")

# create entites
codexkg.create_entity(MY_CSV, "MY_ENTITY", "entity_key")

Happy to chat further if you want a deep dive with Codex

1 Like

Hello,
I am getting an error while importing CodexKg. I have already installed the codex library.

ImportError: cannot import name ‘CodexKg’ from ‘codex’ (C:\Users\amaad\Anaconda3\lib\site-packages\codex_init_.py)

I further try to install CodexKg but they are asking for the CodexKg version, I don’t know about the CodexKg version.
Any solution.
Thanks;

The example above was pseudo-code.

The wiki has more detailed instructions on how to install and use codex.


You can also install codex via pip

pip install grakn-codex