Sign in to follow this  
Followers 0
ra95

Compare 2 file with more data and tab delimiter

4 posts in this topic

#1 ·  Posted (edited)

Hi gui that is my problem:

I have 2 file file1.txt and file2.txt in a first file there are more data delimited by TAB

I not insert tab in example ^^

Es. file1.txt

article1 100 50 33 09 44 55 66 77 13:00:00

article2 110 44 78 99 00 35 67 66 13:01:00

article3 190 44 58 99 00 39 67 68 14:01:00

and more ...

Es. file2.txt

article3 190 44 58 99 00 39 67 68 14:01:00

article1 100 50 33 09 44 33 66 77 14:00:01

article2 110 44 78 99 00 39 67 68 14:01:00

Now i want check if for article1, article2 ....

If time elapsed is superior at 1 hour and if the number 55 (col 7) is changed or not.

Whit this criteria i can control one o more col for example col 7 and 9 ore more ...of same article

I think the best solution is a index for first columb (article)

If have not canghe (prductivity have problem)for me is same if increment or decrease number, for me must have identically number.

If have a canghe (productivity is ok)

every hour the file1 is deleted and file2 is renamed file1, and new file2 with new data are write from other program.

can i realize this control???

Thx in advance

Ra95

Edited by ra95

Share this post


Link to post
Share on other sites



As far as I understand you question, U can follow this approach:

First read all lines in the file and store them in an array by using _FileReadToArray()..

Then take each element of this array and split it, using stringsplit($element," ") by using space as ur delimiter.

Now the array generated due to StringSplit() will have the 1st element as "aricle1" "article2" etc.. Check for the array with artice 1 and 2..

read their 8th element, which will be the number in column 7, as u have described above//

Store this in a variable..

Compare these variable generated from both the files.. and you are done!!

This is an approach you will need to follow.. I do not provide readymade code.. So try to develop a code on these lines and ask me if you get stuck!!

I will definitely help you then!!


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Hi I have search in a forum ad i have find a good solution for grab in array file.

I have use _ArrayFileToArray, and now i have 2 array with 9 column.

here my code:

Func compare()

$Ft0 = FileGetTime(@WorkingDir & "\situazione_step0.txt",1)
$hhmmss0 = _TimeToTicks($Ft0[3],$Ft0[4],$Ft0[5])

$Ft1 = FileGetTime(@WorkingDir & "\situazione_step1.txt",1)
$hhmmss1 = _TimeToTicks($Ft1[3],$Ft1[4],$Ft1[5])

$FTD = ($hhmmss1 - $hhmmss0)

If  $FTD >= 3600000 Then
$FileArray0 = _ArrayFileToArray($statcfile0, @TAB)
$FileArray1 = _ArrayFileToArray($statcfile1, @TAB)

For $ix = 0 To UBound($FileArray0)-2
$aArray_1 = $filearray0[$ix+1][0]
$aArray_2 = $filearray1
If _ArraySearch($aArray_2, $aArray_1) <> -1 Then
$chk = _ArraySearch($aArray_2,$aArray_1,0,0,0,True)
If $chk >= 1 Then
    If $aArray_2[$chk][5] < $FileArray0[$ix+1][5] and $aArray_2[$chk][4] = $FileArray0[$ix+1][4] and $aArray_2[$chk][3] = $FileArray0[$ix+1][3] Then
        $best = FileOpen ($Filebest,1)
        FileWriteline ($Filebest,$filearray1[$ix+1][1] & @CRLF )
        FileClose ($Best)
    endif
    EndIf   
EndIf
Next
EndIf
EndFunc

That is my solution but every suggest is appreciate. ^^

Share this post


Link to post
Share on other sites

Ok great if u have reached the answer!! I have never heard of _ArrayFileToArray()..


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0