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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

how to validate the input file

Hi,
Is there a way to validate the input file according to some conditions before the process ?
For example, if the input file's record number in Footer (one column names records_total) is 100, but the actual input rows are 95. Then I will reject the file and log into the rejected table. Otherwise, I will go to normal process.
My first though was tJava, but it is not that dorable.
Thanks !
James
Labels (3)
10 Replies
alevy
Specialist
Specialist

Not automatically. You'd have to read the last row and count the number of lines and compare them yourself.
Anonymous
Not applicable

Thanks for your reply.
Then, is there a way to read the last line (or particular line) ?
Thanks !
James
alevy
Specialist
Specialist

To read a particular line, you would set the header to be the number of rows before and the limit to 1.
Reading the last line is not so easy. I think you would have to count the rows in the file and use that (minus 1) as a variable for the header of your input component.
_AnonymousUser
Specialist III
Specialist III
Author

Thank you for the reply.
I am think below process,
tFileList
--> tFileInputPositional { if I set the header to limit = 1, I only get one record, but if file is valid, I will process all records} --> tJava{1. how to get the previous line as method input parameter ?, 2. how to output the method result of "if... else if ...."} --> tmap {1. how to get the tJava "if ...else..." result here and map the previous input file } ---> table1, ---> reject records, ----> reject files
Is it doable ? If yes, could you help to answer questions above?

Thanks !
James
Anonymous
Not applicable

Here is the picture for previous process.
0683p000009MEtu.png
alevy
Specialist
Specialist

Header and Limit are two different parameters.
Use tFileRowCount to count the number of rows in the file, then use the globalMap variable it creates in tFileInputPositional to read just the last line and pass it to tJavaRow. You can then have RunIf triggers from tJavaRow to your processing if the file passes validation or if the file fails validation.
tFileList -iterate-> tFileRowCount -iterate-> tFileInput -row-> tJavaRow -if-> tFileInput -row-> tMap -row-> ... (valid file)
(1 row) (full file)
-if-> tSendMail (or whatever for invalid file)
Anonymous
Not applicable

Thanks for your message.
But I have a detail question about "-if" for tJavaRow -if-> tFileInput -row->
In tJavaRow, I set a Boolean variable "valid", how can I access this varialbe's value in "if" condition ?
In old posts, you once mentioned the RUN IF can only access the global variable. Do I need a tSetGlobalVar between tJavaRow -if-> tFileInput -row-> ?
James
Anonymous
Not applicable

OK, I got it.
I can set the global variable in jJavaRow.
thanks !
James
alevy
Specialist
Specialist

You don't actually need to set a global variable in tJavaRow and reference that in the RunIf; you can just put the same boolean expression you're using in tJavaRow directly in the RunIf (although you have to use the real row names instead of input_row).