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: 
Anonymous
Not applicable

multiple tables in a sheet and stop load script manually

Hi guys,

          I wuold your opinion about my strategy.

This is the situation: I've an excel with one sheet and inside this there are multiple tables.

Each table is separated from the next one by two empty rows.

I want load the table from the beggining of the sheet and every time that I found an empty row I want increment a variable by 1.

Furthermore I want add where condition at the end of load script: when variable's value is >= 2 I'll stop the load script.

What do you think about this strategy?


How can I force the exit from load script?


Thanks.


1 Solution

Accepted Solutions
marcus_sommer

This couldn't be done with single-load else you will need a multi-step approach.

This could be for example to load the whole sheet with all the tables into a single table, identifying each sub-table (header and data separate) with various check-statements and then splitting the tables again with the help of these identifying-data whereby you need an additional step to extract the table-header and creating a mapping table for an appropriate rename-statement.

Another approach would be to use the FIRST statement in combination of the (... HEADER is n lines ...) from the file-format. But with this method you must also know when a table begins and end - this meant you need before a load which identified them by using recno(), rowno() and various check-statements maybe in combination with interrecord-functions like peek() or previous(). With this kind of data you creates a for loop which picked the first/header information into variables which is then used within the load-statements.

The second approach here is in my opinion the easier one and with a quick look in the help to the mentioned statements and functions you could start and I think with a few trials you will understand the above described logic and after them it's just a matter of adjusting the identifying routines.

Peek() or Previous() ?

RecNo or RowNo?

Loops in the Script

- Marcus

View solution in original post

2 Replies
arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Andrea,

How can I force the exit from load script?


Use Exit Script function in script level.


Thanks ,

Arvind Patil

marcus_sommer

This couldn't be done with single-load else you will need a multi-step approach.

This could be for example to load the whole sheet with all the tables into a single table, identifying each sub-table (header and data separate) with various check-statements and then splitting the tables again with the help of these identifying-data whereby you need an additional step to extract the table-header and creating a mapping table for an appropriate rename-statement.

Another approach would be to use the FIRST statement in combination of the (... HEADER is n lines ...) from the file-format. But with this method you must also know when a table begins and end - this meant you need before a load which identified them by using recno(), rowno() and various check-statements maybe in combination with interrecord-functions like peek() or previous(). With this kind of data you creates a for loop which picked the first/header information into variables which is then used within the load-statements.

The second approach here is in my opinion the easier one and with a quick look in the help to the mentioned statements and functions you could start and I think with a few trials you will understand the above described logic and after them it's just a matter of adjusting the identifying routines.

Peek() or Previous() ?

RecNo or RowNo?

Loops in the Script

- Marcus