Skip to content

Instantly share code, notes, and snippets.

@infinite-Joy
Created November 2, 2018 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infinite-Joy/57a2de636fc97c1a25201e41c54e4401 to your computer and use it in GitHub Desktop.
Save infinite-Joy/57a2de636fc97c1a25201e41c54e4401 to your computer and use it in GitHub Desktop.
with open("emb/movies.emb", "r") as movies_file, driver.session() as session:
next(movies_file)
reader = csv.reader(movies_file, delimiter=" ")
params = []
for row in reader:
movie_id = row[0]
params.append({
"id": int(movie_id),
"embedding": [float(item) for item in row[1:]]
})
session.run("""\
UNWIND {params} AS param
MATCH (m:MovieId) WHERE id(m) = param.id
SET m.embedding = param.embedding
""", {"params": params})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment