One Star

Preparation of data with Talend

Hello to everybody and sorry for my bad english,
I have a project to do with Talend but I'm stuck in a task, and I don't know how to do.
I have a txt file in this format : 

2015 01 01 -89.5 -179.5 1.0 262 262 262 262 262 262 262 262 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 260 260 260 260 260 260 260 260 260 260 260 261 261 260 260 260 260 260 260 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 262 262 262 262 262 262 262 262 262 262 262 262 262 263 263 263 263 263 263 263 263 263 263 263 263 263 264 264 264 264 264 264 264 264 264 264 265 265 265 265 265 265 265 265 265 265 265 266 266 266 266 266 266 266 266 266 266 266 266 267 267 267 267 267 267 267 267 267 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 268 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267

2015 01 01 -88.5 -179.5 1.0 259 259 259 259 259 259 259 259 258 258 258 258 258 258 257 257 257 257 257 257 256 256 256 256 256 256 256 256 256 256 256 256 256 256 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 256 256 256 256 256 256 256 256 256 256 256 256 256 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 258 258 258 258 258 258 259 259 259 259 259 259 259 260 260 260 260 260 260 260 260 260 260 261 261 261 261 261 261 261 261 262 262 262 262 262 262 263 263 263 263 263 263 263 263 264 264 264 264 264 264 264 265 265 265 266 266 266 266 267 267 267 267 267 267 267 268 268 268 268 268 268 269 269 269 269 269 269 269 269 270 270 270 269 270 270 270 270 270 270 270 270 270 270 270 270 270 270 269 269 269 269 269 269 269 268 268 268 268 268 268 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 266 266 266 267 267 267 267 267 267 267 267 267 267 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 264 264 264 264 264 264 264 264 264 264 264 264 263 263 263 263 263 263 262 262 262 262 262 262 262 262 262 261 261 261 261 261 261 261 261 261 260 260 260 261 261 260 261 261 260 260 260 260 261 261 261 261 261 261 261 261 261 261 261 261 261 261 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262 262


a lot of rows like this.
I want to create a schema with the columns ( Year, Month, Day, longitude, latitude, X, Values -in this field i want to store all the remaining values in the same line but I dont know how. 
I don't know how to do to put a screenshots so i give you the links :
http://www.developpez.net/forums/attachments/p204305d1458324501/logiciels/solutions-d-entreprise/bus...
http://www.developpez.net/forums/attachments/p204306d1458324504/logiciels/solutions-d-entreprise/bus...
http://www.developpez.net/forums/attachments/p204307d1458324507/logiciels/solutions-d-entreprise/bus...

As you see in the screenshots when I do this treatment I have just the first value stored in the last column.
So if you have an idea how to solve this problem, I would be very thankful to you.

1 REPLY
Twelve Stars

Re: Preparation of data with Talend

OK, this might require a bit of lateral thinking. It looks like each value will have a single space separating it from another value. It also looks like the first 6 values will always be provided and are required in their own columns. The rest are required in a single column. Do you know you can guarantee those rules for the whole dataset? If so, some simple Java may help you work with this. You *could* use a simple loop to iterate over the first 6 columns and leave the remaining data in the 7th column.
To do this you could use a tJavaRow component and use some Java like below....
String data = input_row.my_column;
String[] values = new String;
for(int i = 0; i<6; i++){
   values = data.substring(0, data.indexOf(" "));
   data = data.substring(data.indexOf(" ")+1);
}

output_row.col1 = values;
output_row.col2 = values;
output_row.col3 = values;
output_row.col4 = values;
output_row.col5 = values;
output_row.col6 = values;
output_row.col7 = data;

.....to provide 7 columns with the data split as you wish. Obviously these are all Strings in this example so you may want to cast to other types and the long String of values you may want to convert to a List (this can be done with some extra processing of the "data" variable before assigning it to col7....check out ArrayLists in Java).
Rilhia Solutions