Read a 100 MB xlsx file to parse it in java and save to mongodb? Fast

I want to read the xlsx file and save it in the mongodb.file file. Minimum file size: 100mb. I want to read an xlsx file and parse it in json and save it in mongodb.

+4
source share
1 answer

You can read XLSX files using Apache POI (as described here http://java67.blogspot.com/2014/09/how-to-read-write-xlsx-file-in-java-apache-poi-example.html )

Since mongodb has a 16 MB limit per document ( 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 actually have many small documents in an XLSX file (for example, on each line), you can use the batch method of inserting documents into blocks (see How to insert several documents at once into MongoDB via Java as an example).

+2
source

Source: https://habr.com/ru/post/1607318/


All Articles