Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone!
Let's imagine we have this load statement that we execute e.g. once a week:
[data]:
LOAD
[Reservation id],
[ID member],
[Code MA],
[Registration date],
FROM [lib://Folder/file.csv]
(txt, codepage is 28591, embedded labels, delimiter is '\t', msq)
But .csv coding from file.csv might change from one week to another, and instead of:
(txt, codepage is 28591, embedded labels, delimiter is '\t', msq)
This week's coding will be:
(txt, utf8, embedded labels, delimiter is ';', msq);
So we'll get a 'Field xxxx not found' error when executing our script.
Is there any way to load [data] table again using an alternative .csv coding when such an error occurs?
I tried using the 'ScriptError' function with no success on my script. Could anyone help with this issue?
Thanks in advance for your help,
Jose.
Can you share the error handling script you used?
Hope you set the errormode to 0
below has worked for me in past
set ErrorMode=0;
load * from abc.csv;
if ’$(ScriptError)’=’File Not Found’ then // or if ScriptError=8 then
//execute the error handling statements
end if
in your case script error should 11 ofcourse
Can you share the error handling script you used?
Hope you set the errormode to 0
below has worked for me in past
set ErrorMode=0;
load * from abc.csv;
if ’$(ScriptError)’=’File Not Found’ then // or if ScriptError=8 then
//execute the error handling statements
end if
in your case script error should 11 ofcourse
I tried this:
set ErrorMode=0;
[data]:
LOAD
[Reservation id],
[ID member],
[Code MA],
[Registration date],
[Agent name]
FROM [lib://Folder/file.csv]
(txt, utf8, embedded labels, delimiter is ';', msq);
if ScriptError=11 then
[data]:
LOAD
[Reservation id],
[ID member],
[Code MA],
[Registration date],
[Agent name]
FROM [lib://Folder/file.csv]
(txt, codepage is 28591, embedded labels, delimiter is '\t', msq);
end if
Hm.. weird
I just tried simulating the issue with a wrong column name and it worked.
Try debugging and check exact text of the ScriptError. and/or try use the text comparison
maybe its 12 not 11
below from help page
11 | Field not found |
12 | File has wrong format |
Hi!
You were right. Script executes and it loads data from file.csv, but still a message "errors were found during execution" is shown in data load progress window.
Is there any way to avoid this?
Hola Jose,
As far as know there's no way to avoid this error message. What I do is to write a message in a TRACE saying that it's not an error and the message should be ignored.
Hope this helps.
Jay
Good idea! Thanks everyone for your help.
Jose