I want to read xlsx file and store into the mongodb.file Size is minimum 100mb.I want to read the xlsx file and parse it into json and store it into mongodb..
Asked
Active
Viewed 966 times
1 Answers
2
You can read XLSX files using Apache POI (like described here http://java67.blogspot.com/2014/09/how-to-read-write-xlsx-file-in-java-apache-poi-example.html).
Since there is a limitation in 16 mb per document in mongodb (http://docs.mongodb.org/master/reference/limits/) you might want to use GridFS to write raw data. Here is an example how to do it:
https://blog.codecentric.de/en/2012/11/mongodb-supplemental-gridfs-example-in-java/
[UPDATE] If you have actually many small documents in XLSX file (like document per row) then you can use batch-like way inserting documents by blocks (see How to insert multiple documents at once in MongoDB through Java as an example).
-
3Thanks rsutormin. i tried this one ,but i want to read greater than 100mb file in every two seconds in within two seconds i have to parse it and save to mongoDb gridfs I used gridfs i want to do it in minimum Timespan like two seconds. My whole data is in petabyte..but i take this sheets from URl in rest. – sachin Sep 15 '15 at 05:10
-
Another question is if the speed is so critical then why don't you deal with CSV-files instead which could be imported into MongoDB with help of standard tools (http://stackoverflow.com/questions/4686500/how-to-use-mongoimport-to-import-csv)? – rsutormin Sep 15 '15 at 06:30