Skip to content

Java parser for R data file?

4 messages · Brian Ripley, Michael Hoffman, David Coppit

#
Hi everyone,

Has anyone written a parser in Java for either the ASCII or binary format
produced by save()? I need to parse a single large 2D array that is
structured like this:

list(
  "32609_1" = c(-9549.39231289146, -9574.07159324482, ... ),
  "32610_2" = c(-6369.12526971635, -6403.99620977124, ... ),
  "32618_2" = c(-2138.29095689061, -2057.9229403233, ... ),
        ...
)

Or, given that I'm dealing with just a single array, would it be better to
roll my own I/O using write.table or write.matrix from the MASS package?

Thanks,
David
#
On Wed, 5 Dec 2007, David Coppit wrote:

            
It would be much easier.  The save() format is far more complex than you 
need.  However, I would use writeBin() to write a binary file and read 
that in in Java, avoiding the binary -> ASCII -> binary conversion.
#
David Coppit wrote:
You might want to consider using the hdf5 package to save the array in 
HDF5 format. There are HDF5 libraries for Java as well 
<http://hdf.ncsa.uiuc.edu/hdf-java-html/>. I have never used them, but 
it works quite well for transferring data between R and Python.