Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
JayZ1
Contributor III
Contributor III

How to dynamically go through CSV file

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?

Labels (3)
2 Replies
gjeremy1617088143
Master
Master

Hi @Harjot Toor​ , do you work on a suscribed edition of talend or open studio ?

gjeremy1617088143
Master
Master

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(",$","");