Question

Importing Python module in Jython Stage

  • 13 January 2023
  • 2 replies
  • 72 views

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

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

Userlevel 5
Badge +1

@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