Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm struggling to read a local file and get the contents into a java list for processing.
For example, the file might contain:
cat
dog
mouse
and the java list would be populated with these 3 values.
I had assumed tfileinputdelimited would work but it always wants create name/value pairs whereas I just want a list of values.
Thanks
Andy
Talend works using the concept of rows and columns. If you are reading data from a CSV file, that is data stored in a row/column fashion. However, you can assign your data into any Java object you like. Just use a tJavaFlex with code like this....
Start Code
// start part of your Java code java.util.ArrayList<String> al = new java.util.ArrayList<String>();
Main Code
// here is the main part of the component, // a piece of code executed in the row // loop al.add(row2.animal);
End Code
// end of the component, outside/closing the loop globalMap.put("al", al);
In the above I am creating an ArrayList, assigning each row's "animal" column value to it and then storing the ArrayList in the globalMap to be used anywhere else in the job.
Talend works using the concept of rows and columns. If you are reading data from a CSV file, that is data stored in a row/column fashion. However, you can assign your data into any Java object you like. Just use a tJavaFlex with code like this....
Start Code
// start part of your Java code java.util.ArrayList<String> al = new java.util.ArrayList<String>();
Main Code
// here is the main part of the component, // a piece of code executed in the row // loop al.add(row2.animal);
End Code
// end of the component, outside/closing the loop globalMap.put("al", al);
In the above I am creating an ArrayList, assigning each row's "animal" column value to it and then storing the ArrayList in the globalMap to be used anywhere else in the job.