Forum Discussion

wynandb1's avatar
wynandb1
Contributor
11 years ago

Verify fields in text files

Good day

 

I have the following jscript to compare two text files with each other. I compare the master file to the newly exported file. 

 

However in the script the new file has a constant name, but this will not be the case. When the file is exported, the file name changes. The file name has the current date in and the current time eg. file_name_20150507_1430.txt So the variable in the name is the date and time. 

 

I have 2 types of files Master File A and B. I need to compare and verify file Master File A with a newly exported file A and the same with file B. 

 

File A and B format differs inside the file. 

 

File A = Line 1 = Constant value =  (FILEMK\\\\\#END#|) Starting from column 1 to 17 and should not go over column 17

 

File A = Line 2 = Almost everything in this line will be a variable. So I think the best way is to compare is to make sure the data stops at column 268 in line 2 ? 

 

File A = Line 3 = Constant value =  (#END#|) Starting from column 1 to 6 and should not go over column 6

 

 

File B = Line 1 = Constant value = (Pan,Track2,Barcodeen128,seq_no,Tracer_no,CoBranding) Starting from column 1 to 17 and should not go over column 51

 

File B = Line 2 = Almost everything in this line will be a variable. So I think the best way is to compare is to make sure the data stops at column 118 in line 2 ? 

 

I did the file compare in a keyword test and converted it to script. This is what I have. 

 

Could someone perhaps help me with this ? 

 

function Test6()
{
var Var1;
Var1 = "yymmdd";
//Returns True if the file stored in the Files collection under the specified name and another file are absolutely identical. Otherwise, it returns False.
Files.Compare("C:\\Foldername\\Foldername\\Foldername\\SBK_CLASC_201505071232RT.txt", "C:\\Foldername\\Foldername\\SBK_CLASC_201505071436RT.txt");
}

 

2 Replies

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hi,

    You want to store a baseline file within the test execution and compare it in the same time to another file ?

    • wynandb1's avatar
      wynandb1
      Contributor

      Hi

       

      I wish it was that easy. The thing is that a big part of the file is a variable. I only need to verify certain parts of the file due to that. 

       

      That's why I need someone's help with script to achieve that. The file layout is explained above. I unfortunately do not have programming skills to do this.