Skip to main content
Question

Importing Python module in Jython Stage


I am trying to use Jython Stage to process the JSON data as it is bit complex JSON.

I used below code to import python module but getting error,

 

Code : 

try:
  sdc.importLock()
  import sys
  sys.path.append('/python/sdc-packages')
  import json_normalize
finally:
  sdc.importUnlock()

 Error :

com.streamsets.pipeline.api.StageException: SCRIPTING_06 - Script error while processing batch: javax.script.ScriptException: ImportError: No module named json_normalize in <script> at line

 

If you can advise.

2 replies

XavierV
StreamSets Employee
  • StreamSets Employee
  • 10 replies
  • January 13, 2023

Hi!

  1. is the package really installed in '/python/sdc-packages'?
  2. that said, are you thinking about using https://pypi.org/project/json-normalize/ ? It’s for Python 3.7+, while Jython runs Python 2.7

Hope this helps,

-Xavier


Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • January 13, 2023

@yogesh0590 

 

can you please try (import json ) in jython processor because it handles json data in it .

It works for me and hope it will help you.


Reply