SHARE
TWEET

Untitled

a guest Jun 25th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from gremlin_python import statics
  2. from gremlin_python.structure.graph import Graph
  3. from gremlin_python.process.graph_traversal import __
  4. from gremlin_python.process.strategies import *
  5. from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
  6. import pandas as pd  
  7.  
  8. graph = Graph()
  9. g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
  10. g.V().drop().iterate()
  11.  
  12. md = pd.read_csv('mydata.csv')
  13. print(md.head())
  14.  
  15. t = g.addV('user').property('NA',0).property('NA',0)
  16.  
  17. for index,row in md.iterrows():
  18.     t.addV('user').property(row['c_001']).property(row['c_002'])
  19. t.iterate()
  20.      
  21. Unnamed: 0        c_001  c_002  c_003  c_004  c_005        c_006  
  22. 0           1  65949875906      0     17      6   1939  75070365946  
  23. 1           2  68409888823      0     13      7   1991  90996121578  
  24. 2           3  56828298827      1     10     10   1917  20903355855  
  25. 3           4  88325530620      0     30      9   1940  84418725200  
  26. 4           5  31899541106      0      9      9   2007  97820489525
  27.  
  28. Traceback (most recent call last):
  29.   File "tst3.py", line 20, in <module> t.iterate()
  30.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py",
  31. line 57, in iterate try: self.nextTraverser()
  32.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py",
  33. line 61, in nextTraverser self.traversal_strategies.apply_strategies(self)
  34.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py",
  35. line 346, in apply_strategies
  36. traversal_strategy.apply(traversal)
  37.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/remote_connection.py",
  38. line 143, in apply remote_traversal = pself.remote_connection.submit(traversal.bytecode)
  39.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/driver_remote_connection.py",
  40. line 53, in submit result_set = self._client.submit(bytecode)
  41.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/client.py",
  42. line 104, in submit return self.submitAsync(message, bindings=bindings).result()
  43.   File "/usr/lib/python3.5/concurrent/futures/_base.py",
  44. line 405, in result return self.__get_result()
  45.   File "/usr/lib/python3.5/concurrent/futures/_base.py",
  46. line 357, in __get_result raise self._exception
  47.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/connection.py",
  48. line 63, in cb  f.result()
  49.   File "/usr/lib/python3.5/concurrent/futures/_base.py",
  50. line 398, in result return self.__get_result()
  51.   File "/usr/lib/python3.5/concurrent/futures/_base.py",
  52. line 357, in __get_result raise self._exception
  53.   File "/usr/lib/python3.5/concurrent/futures/thread.py",
  54. line 55, in run result = self.fn(*self.args, **self.kwargs)
  55.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/protocol.py",
  56. line 65, in write request_id, request_message)
  57.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/serializer.py",
  58. line 128, in serialize_message
  59. message = self.build_message(request_id, processor, op, args)
  60.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/serializer.py",
  61. line 138, in build_message return self.finalize_message(message, b"x21", self.version)
  62.   File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/serializer.py",
  63. line 141, in finalize_message message = json.dumps(message)
  64.   File "/usr/lib/python3.5/json/__init__.py",
  65. line 230, in dumps return _default_encoder.encode(obj)
  66.   File "/usr/lib/python3.5/json/encoder.py",
  67. line 198, in encode chunks = self.iterencode(o, _one_shot=True)
  68.   File "/usr/lib/python3.5/json/encoder.py",
  69. line 256, in iterencode return _iterencode(o, 0)
  70.   File "/usr/lib/python3.5/json/encoder.py",
  71. line 179, in default raise TypeError(repr(o) + " is not JSON serializable")
  72. TypeError: 65949875906 is not JSON serializable
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top