Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-05-2019 06:42 AM
Hi everyone,
I'm working with a recommender system that connects players and games (games as in matches). I started to play with py2neo trying to import a dummy DB from a csv with the following info:
|gameId|userId|
|Game1|1,2,3,6|
|Game2|1,2,5,6|
|Game3|3,4,6,7|
|Game4|3,4,2,5|
This is what I do to create the graph (constraints are already in place)
csv_players_df= pd.read_csv(path+'games-users1.csv')
tx = g.begin()
for index, row in csv_players_df.iterrows():
tx.evaluate('''
WITH split($userId,",") as users
UNWIND users as user
MERGE (p:Player {userId:user})
MERGE (g:Game {gameId:$gameId})
MERGE (p)-[:played_in]->(g);
''', parameters = {'userId': row['userId'],'gameId': row['gameId']})
tx.commit()
The code executes without any issues. However, when displaying the graph in neo4j, user ids are not displayed for the nodes. There must be something wrong with my UNWIND but I cannot figure it out.
I know userIds are correctly inserted though:
When testing the same code directly in neo4j I see the IDs are displayed correctly:
This is the code for neo4j:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
'file:///games-users1.csv' AS row
WITH row, split(row.userId, ",") AS users
UNWIND users AS user
MERGE (p:Player {userId: user})
MERGE (g:Game {gameId: row.gameId})
MERGE (p)-[:played_in]->(g);
What am I missing here?
Thanks! Raul.
Solved! Go to Solution.
06-05-2019 11:45 AM
This just looks like a question of what to display, doesn't look like there's anything wrong with your load.
In the graph display pane, click on the label associated with the orange nodes (where it has the label name and the count of those nodes). At the bottom of the pane it should show some options of what properties to use for display. Click he userId property and the display should update accordingly.
06-05-2019 11:45 AM
This just looks like a question of what to display, doesn't look like there's anything wrong with your load.
In the graph display pane, click on the label associated with the orange nodes (where it has the label name and the count of those nodes). At the bottom of the pane it should show some options of what properties to use for display. Click he userId property and the display should update accordingly.
06-05-2019 10:57 PM
Thanks Andrew.
feeling stupid know
I thought there was something wrong as it wasn't showing it by default
All the sessions of the conference are now available online