Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
phil-ebm
Creator
Creator

Check file structure (e.g. txt-file) before loading data

Hello Community

I searching a lot but couldn't find a solution for my problem.

In my case i have a folder where all measure files from our products are saved as a txt-file. With qlikview I want to load all the files into a datamodel so we can work with this data.

No my problem is that some of these files are corrupt or not complete and I don't want to load this data into my model. A File is corrupt for example when not all columns are available.

When I just load the data into my model then I get an error when I arrive at a corrupt file and the load stops.

Now my plan is to check if the number of available columns in the txt-file is equal to the need columns and then i will load the data.

Have someone expriences here how I can do that?

Regards

3 Replies
m_woolf
Master II
Master II

You can use error handling to skip the files that produce errors.

phil-ebm
Creator
Creator
Author

Thanks for your reply but how you would do this?

Because setting errormode = 0 then i get no error message but normaly I want all messages.

marcus_sommer

Error handling means normally more than just setting the erromode to 0 and ignoring all errors else to enable the errormode and disable it afterwards probably multiple times during the script - and also querying the error-status after the statements and re-acting on the results, for example no error happens just go on, an uncritical error occured just trace this error within the log-file or maybe a critical error happens and you want to exit the script.

This could be quite expensive but sometimes there is no alternatively for such an approach. But in your case you could avoid it if you read the table-structure and comparing it against the target-structure before you made the real load. Maybe with something like this:

Check:

first 1 load * from Source;

Fields:

load fieldname(recno(), 'Check') as Fields autogenerate nooffields('Check');

This table could be compared against your target maybe with some joining/mapping or aggregating it to fieldlist-string. There are various ways possible. After them you could know if the file is valid or not and you could just skip it without using the error-mode.

- Marcus