CSV import

0
Hi, I want to import CSV-files into my application. In order to that, I've downloaded the CSV module from the App Store. However, I don't get it started. Hopefully somebody can help. I've followed the steps that are described in the documentation. I've created an entity to store the CSV-file (CsvTransactionFile), than I created an entity to store all the lines inside the CSV-file (EntryLineFromCsv), with an attribute corresponding to every column of the CSV. My domain model looks as follows: When I add a CSV-file, in the CommitFile microflow I want to import all the lines inside the CSV. However, the Java action ‘Import CSV’ is not very clear to me which inputs I have to fill in. Can somebody point me the right way of how to use this Java action and how the microflow should look like? Thanks in advance for your help.
asked
3 answers
3

Hi Pieter,

I downloaded the example file as suggested from ttps://www.rabobank.nl/images/voorbeeldbestand-csv-extensie-excel_29933460.zip .

I am able to import the data successfully. Here is my example. The dummy CSV file is saved in my resources folder as “test.csv”.  I haven’t named all the attributes in the CSV entity as Dutch isn’t my first language.

Firstly I load the test.csv file from my resources directory using the GetFileContentsFromResource action from the Community Commons library. I pass this into ImportCSV.

 

My ImportCSV action looks like this.

This calls my ReadLine_CSV microflow. This iterates every line, adding to a list, before finally committing it.

I hope this helps you!

answered
0

When I’ve used the CSV module I’ve had my equivalent of the EntryLineFromCSV entity as a non persistent entity with no associations. 

Your “Read Next Line” should populate EntryLineFromCSV when it reads the line. If this is empty, it’s the end of the file. I would use this to create a new Entry and persist this. Remember to then loop back to call “Read Next Line” again if your EntryLineFromCSV wasn’t empty.

 

answered
0

Hi Robert, thanks for your response. I've changed the domain model, it now looks like:

 

The MF to invoke in the Import CSV  action looks as follows:

Now, 3 EntryLineFromCsv objects are created (the CSV-file contains 3 rows). However, how do I get all the data from the CSV into the different attributes of the EntryLineFromCsv?

Thanks!

answered