Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Banupriya
Contributor II
Contributor II

Sort the data in the file which is having different schema.

Hi,

I need to sort the data in the file which is having different schema. Schemas we know only on run time. First 4 columns are same. We can not define dynamic schema because it's taking the structure of first row data and appending delimiter to other rows which is having less columns. ​

Could any one help me here. ​

Need to sort the data having different schema.

Thanks,

Banupriya​

Labels (3)
3 Replies
gjeremy1617088143
Creator III
Creator III

Hi, maybe you can read data row by row in one field then

you parse with a delimiter to see the number of field and you drive data in function to that.

Send me love and kudos

Banupriya
Contributor II
Contributor II
Author

Thank you for the reply. We are not sure how many columns we are going to get in the file. so we can not define a field counts anywhere. ​

gjeremy1617088143
Creator III
Creator III

dynamic shema allow you to do that, you have just to select only one otuput field with dynamic type on the input component, then you can do what you want with :

count the field numbers, add column,supress suppress ,shuffle the column etc.

here a code example to get all column name and values of dynamic object :

if the output field of your input component is for example data (type dynamic):

 

Dynamic columns = row1.data;

for (int i = 0; i < columns.getColumnCount(); i++)

{

DynamicMetadata columnMetadata = columns.getColumnMetadata(i);

String inp_col=columnMetadata.getName().toString();

String col_val=(String)row1.data.getColumnValue(inp_col);

}

do you have a header in the file or each row have is own schema ?

maybe you could send an exemple of file you have