Avatar

Level 4

Hi @kotisyamala ,


I don't think you might be able to check the file header efficiently using data loading itself. I would suggest you use a shell script activity or a JS activity for this evaluation. The shell script could be as following:

 

fileA="path to the file downloaded"
fileB="path to file with header"

head -1 $fileA | grep "$(cat $fileB)"
if [[ $? -ne 0 ]] ;
then
echo "fileA header does not match with fileB"
exit 1;
fi

 

You may also use an Advanced JavaScript code activity with the following code:

 

var fileA="path to the file downloaded"
var fileB="path to file with header"

var file = new File(fileA);
file.open("r", File.CODEPAGE_UTF8);

var headerOfDownload = file.readln();
var originalHeader = loadFile(fileB,"utf-8")
logInfo(headerOfDownload);
logInfo(originalHeader);
if(headerOfDownload.trim() == originalHeader.trim()) {
task.postEvent(task.transitionByName('match'));
} else {
task.postEvent(task.transitionByName('nomatch'));
}

 

 

You can use the 'nomatch' transition to alert the respective operators. Hope it helps!