ra95 Posted August 19, 2009 Share Posted August 19, 2009 (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 TABI not insert tab in example ^^ Es. file1.txtarticle1 100 50 33 09 44 55 66 77 13:00:00article2 110 44 78 99 00 35 67 66 13:01:00article3 190 44 58 99 00 39 67 68 14:01:00and more ...Es. file2.txtarticle3 190 44 58 99 00 39 67 68 14:01:00article1 100 50 33 09 44 33 66 77 14:00:01article2 110 44 78 99 00 39 67 68 14:01:00Now 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 articleI 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 advanceRa95 Edited August 19, 2009 by ra95 Link to comment Share on other sites More sharing options...
Manjish Posted August 20, 2009 Share Posted August 20, 2009 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 Link to comment Share on other sites More sharing options...
ra95 Posted August 20, 2009 Author Share Posted August 20, 2009 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. ^^ Link to comment Share on other sites More sharing options...
Manjish Posted August 20, 2009 Share Posted August 20, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now