Multi-file Association in Java

 

Question
I want to use 10 CSV files in my Java program. Are there any options to build relations between these individual CSV files? For example if I have a CSV file with postal codes and another one with postal codes and city names, how can I connect them? And what packages/classes I can work with CSV in Java? Thanks for your answers!

 

Answer

It’s easy to get it done with esProc SPL. The SPL script is simple and clear:

 

A

1

=file("D:/sOrder.csv").import@ct(OrderID,SellerId,Amount)

2

=file("D:/emp.csv").import@ct(Eid,Name)

3

>A1.switch(SellerId,A2:Eid)

4

=A1.new(OrderID,SellerId.Eid,SellerId.Name,Amount)

A1: Import orders data from sOrder.

undefined

A2: Import employee data from emp.

undefined

A3: Switch A1’s SellerId to A2’s referencing field Eid.

undefined

A4: Get the joining result according to the join fields.

undefined

An SPL script can be integrated with a Java application via esProc JDBC. See How to Call an SPL Script in Java to learn more about the integration.