my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes Most portable format for data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Most portable format for data" Watch "Most portable format for data" New topic
Author

Most portable format for data

Emilio Gagliardi
Greenhorn

Joined: Jun 02, 2004
Posts: 16
Hi just a quick question, what is the best way to store primitive types when writing to a file so that other programs can read/import the data? For example, excel or SPSS.

Cheers,
Emilio


Emilio
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

Emilio,
For Excel, a comma delimitted file is best.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

spss handles csv-files too.


http://home.arcor.de/hirnstrom/bewerbung
Emilio Gagliardi
Greenhorn

Joined: Jun 02, 2004
Posts: 16
This is probably a dumb question but are CSV files written as char?
As in, if I want to store 123456 as an actual integer it would take 4 bytes, as opposed to 12 bytes to store the six characters...is that right? If so, then I must write the numbers and commas and end-of-line characters.

Thank you for your input. =)

Cheers,
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
Why not create a file in Excel and see how it saves it? You'll find, I think, that ultimately you have to write numbers in human-readable format. So I'd be going with a PrintWriter.


-Tim
Richard Rodger
Greenhorn

Joined: Jan 07, 2005
Posts: 17
CSV files are in a plain text human-readable format, so you would output all 6 characters.


Richard Rodger<br /><a href="http://www.ricebridge.com" target="_blank" rel="nofollow">http://www.ricebridge.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Most portable format for data
 
Similar Threads
wordings for error message
PrintWriter vs OutputStream
RMI error
JTree and JTable
JComboBox Problem...Help