The below-mentioned code is working fine but I want to integrate the below-mentioned python script to JVM script to run in SnapLogic tool. Any leads will be very helpful.
import os
import sys
def execute():
file=open("C:/Python27/snaplogic_file.txt","r")
header=next(file)
new_file1=open("C:/Python27/snaplogic_processed_file1.txt",mode='w+')
new_file1.write(header)
new_file1.close()
for line in file:
new_file=open("C:/Python27/snaplogic_processed_file.txt",mode='w+')
new_file.write(line)
execute()
When you select Python in the Script snap it actually means Jython. So, you can, basically, import Java classes in your script.
Following is an implementation where I'm writing a dummy file in the /tmp folder of one of the nodes.
Following is the input JSON to the Script snap.
Check the file in the node.
Note: I use Jackson's ObjectMapper because I mostly deal with JSONs.