Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2014 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9170404 to your computer and use it in GitHub Desktop.
Save anonymous/9170404 to your computer and use it in GitHub Desktop.
Converte Object[][] to PyList of PyLists fails is some null values on Object[][]
Object[][] JavaArray = new Object[2][3];
JavaArray[0][0] = 1;
JavaArray[0][1] = 0;
JavaArray[0][2] = null;// replacing this by anything else would make it work right!
JavaArray[1][0] = 1;
JavaArray[1][1] = 0;
JavaArray[1][2] = 2;
//tried many things here, last ones are uncomented
PyList JythonList = new PyList();
for(int row=0; row<2; row++){
Object[] currow = JavaArray[0];
//PyObject JyArray = Py.java2py(currow);
ArrayList<Object> curlist = new ArrayList<Object>(Arrays.asList(currow));
//PyArray JyArray = new PyArray(currow.getClass(),currow);
//PyArray JyArray = (PyArray)JythonOb;
//PyObject Jyrow = JyArray.tolist();
//System.out.println(curlist.toString());
PyList Pyrow = new PyList(curlist);
/*
for(int col = 0; col<3;col++){
Jyrow.append(JythonOb[col]);
}*/
JythonList.append(Pyrow);
}
//Trying to print produces an error, if you did not find the error before
System.out.println(JythonList.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment