[resolved] Python code - tJython

[resolved] Python code - tJython

Hi,
I am trying to implement a piece of code written in Python in to Talend(TOS). I found a component for this reason tJython but the main point is to interpret the python code to Jython. And the fact is that I am new to Jython. Can someone kindly help me with implementing the code?

this is the Python code:
import csv
from itertools import izip
a = izip(*csv.reader(open("input.csv", "rb")))
csv.writer(open("output.csv", "wb")).writerows(a)

The code is to transpose a csv file from column to row.
Your help is much appreciated.
Pouya

Accepted Solutions
One Star

Re: [resolved] Python code - tJython

I'm a Python n00b, but I think this means you are trying to import the Java class org.python.core.PyException into Jython. Try adding the class to the classpath variables.
Windows > Preference > Java > Buildpath > Classpath Variables

All Replies
One Star

Re: [resolved] Python code - tJython

Hi Pouya,
Did you try the code above? If you did and it didn't work, what was the error you received?
I have not used Jython, but my understanding is that Jython syntax is identical to Python except for using some java specific libraries as collections; it just allows Python to run through the JVM.
This is probably a good reference to get started.
http://www.jython.org/jythonbook/en/1.0/

Best,
Ben

Re: [resolved] Python code - tJython

Hi Ben,
Many thanks for your response.
I created a job so that it emails me when an exception is thrown. And this is the error message I am getting "org.python.core.PyException:null" .
I believe the above code which is a pure Python code must be interpreted for JVM. And that's where Jython comes in which I am not that knowledgeable about.
Thanks for the reference you sent. I will have a look. But in case if the above error code is familiar for you I appreciate your help.
Cheers
Pouya
One Star

Re: [resolved] Python code - tJython

I'm a Python n00b, but I think this means you are trying to import the Java class org.python.core.PyException into Jython. Try adding the class to the classpath variables.
Windows > Preference > Java > Buildpath > Classpath Variables
One Star

Re: [resolved] Python code - tJython

x = input()
y = input()
print x/y