How import many documents with metadata in an Excel file ?

Hi everyone,

I'm trying Nuxeo and I would like to know if there is an easy way to import something like 1000 documents with the matching metadata in an Excel file ?

An example if my explanation is not clear :

I'd like to say that my file is on C:\temp\file.txt and that column A in an excel file contain the title where on column B is my file path.

Thanks

0 votes

1 answers

3482 views

ANSWER



Yes, You can easily do that with Nuxeo if your excel file is a CSV file. If not this can be harder.

But you will need some development skills. I can give the big picture to do that:

  • First you create a Nuxeo plugin project with Nuxeo IDE. See here
  • Then, you will have to create the code that parses the csv file and create your document with information extracted.
... parse your excel file with your preferred csv library...
DocumentModel doc = session.createDocumentModel("/path/into/nuxeo", "your-doc-name", "File");
FileBlob file = new FileBlob(new File(filePathGetFromCSVFile).toURI()));
doc.setPropertyValue("file:content", file);
 ... add more metadata if you want...
 session.createDocument(doc);
  • If you think to create more than 50 documents, you may need to flush sometimes the transaction… To do that, you just have to do that regularly (each 10 documents for instance):

    session.save(); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction();

  • You can attach this treatment to an action or a REST through webengine…

Remark: I strongly recommend to unit test the CSV parsing and document creation if you start Nuxeo Coding.

Hope this will help,

0 votes



Maybe extending the Nuxeo generic importer would be an easier starting point? See http://doc.nuxeo.com/x/zQQz
10/13/2011