How to unzip a file from a folder, and then convert the XML document contained in this file, to a CSV format?
Asked
Active
Viewed 390 times
-3
-
6Those are two unrelated questions. That makes the answers less valuable to the next person to come along. – President James K. Polk Mar 04 '10 at 12:36
-
Try this: http://stackoverflow.com/questions/1080381/gzipinputstream-reading-line-by-line. – Kapil D Mar 04 '10 at 10:57
2 Answers
1
You can simply use the java.util.zip.*
classes to unzip the content of a ZIPped file.
Concerning your conversion from XML to CSV, it is difficult to tell you how you can achieve that without knowing the format of your XML data. However, the simplest thing is to parse the XML, then writing in parallel the content of your CSV file. The CSV format is really simple as it is only values separated by a specific character (generally a ,
;
or a tabulation).

Romain Linsolas
- 79,475
- 49
- 202
- 273
0
To unzip file use: java.util.zip.ZipFile
Converting .xml to .csv is less obvious. One of most popular XML parser is Xerces. Of course you can use XSLT to transform your file.

Michał Niklas
- 53,067
- 18
- 70
- 114