bafh Posted November 12, 2005 Posted November 12, 2005 (edited) Hi folks, well, I got a file (file1) in which are written like 1200 lines. I only need a specific value of each line, so i filtered this one with string actions (stringsplit, stringinstring and so on) Then it writes these values to another file(file2). Now my problem: Some of the values appear twice or even more often in file1 and thus are written twice or mor often in file2. How can i make the script check if the value was already added to file2 and, if so, continue with the next line? Here my script: $line=1 $file="backup.txt" for $line=1 to 1284 $string=filereadline($file,$line) $op1=StringSplit ($string, "Date" ,1) $User=stringsplit($op1[2],"</B>",1) $op2=stringsplit($User[2],"<br",1) $total1=$User[1]&$op2[1] $total2=StringReplace ($total1, "<i>","-") $total3=StringReplace ($total2, "</i>","") FileWriteLine("new file.txt",$total3) next Thanks Edited November 12, 2005 by bafh
ChrisL Posted November 12, 2005 Posted November 12, 2005 (edited) Hi folks,well, I got a file (file1) in which are written like 1200 lines. I only need a specific value of each line, so i filtered this one with string actions (stringsplit, stringinstring and so on)Then it writes these values to another file(file2).Now my problem: Some of the values appear twice or even more often in file1 and thus are written twice or mor often in file2. How can i make the script check if the value was already added to file2 and, if so, continue with the next line?Here my script:$line=1$file="backup.txt"for $line=1 to 1284 $string=filereadline($file,$line) $op1=StringSplit ($string, "Date" ,1) $User=stringsplit($op1[2],"</B>",1) $op2=stringsplit($User[2],"<br",1) $total1=$User[1]&$op2[1] $total2=StringReplace ($total1, "<i>","-") $total3=StringReplace ($total2, "</i>","") FileWriteLine("new file.txt",$total3) nextThanksYou'd have to store the value from file1 in a variable.Open the second file and pretty much do the same as you did before read each line and check for the value of the variable, if it does not exist then read the next line until end of file is reached, if you get to the end then you know you have to write the value to file 2, or if it does exist then jump out of the loop and continue going through file1 Edited November 12, 2005 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
bafh Posted November 12, 2005 Author Posted November 12, 2005 Ye, got it! $line=1 $file="thisfile.txt" for $line=1 to 1284 $check=1 $string=filereadline($file,$line) $op1=StringSplit ($string, "Access" ,1) $op2=StringReplace($op1[2],"</B>","") $op3=StringReplace($op2,"<i>","-") $op4=StringReplace($op3,"</i>","") $op5=StringReplace($op4,"<br>","") $op6=StringReplace($op5,"&","") $op7=StringReplace($op6,";","") $op8=StringReplace($op7,"gt","") $key=stringtrimright($op5,16) $test=filereadline("test.txt") $ok=stringinstr($test,$key) filewrite("test.txt",$key) If $ok=0 then filewriteline("Hello.txt",$op8) next Works fine just needs like 1 minute to do this with all the lines!
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