Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
So I have CSV file:
format:
UserId,Name,Entitlements
user1,Second User,Super Admin
user2,,Super Admin, QA Analyst
user3,First Last,Super Admin
In this case in the third and so on column will be entitlements, some users will have only 1 some will have multiple. How could I make sure these are included when I do a tFileInputDelimted?
Would I have to have my schema be = to the Most number of entitlements a person can have? Or is there a way to make it so that after the first 2 columns everything else is going to be an Entitlement by default, without having to create more columns in my schema?
Hi @Harjot Toor , do you work on a suscribed edition of talend or open studio ?
a simple way could be you read the file line by line
(you can use a tFileinputDelimited with € as split char for eg and only one column as type String on output)
, then you split the string by comma(yourString.Split(",")) then you can set the first split for UserId, the second for Entitlements and you concatenate all the other for Entitlements
in a tJavaRow for eg:
String[] arrays=
(input_row.newColumn).split(",");
String ent = "";
for(int i=0;i< arrays.length;i++)
{
if(i>1)
ent = ent + arrays[i] + ",";
};
output_row.UserId = arrays[0];
output_row.Name = arrays[1];
output_row.Entitlements = ent.replaceAll(",$","");