ARPFre Posted March 28, 2022 Posted March 28, 2022 Hello guys, I'm creating a script that saves information in CSV, so far everything works fine. But I want that before saving in the same file (append new line), check if the content is repeated. I left in the attachment an example of the TXT that contains and the TXT to be replaced. I was able to locate the lines, even replace, but I don't know how to do BEFORE. Original.txt Replace.txt
ad777 Posted March 28, 2022 Posted March 28, 2022 @ARPFre if you want to check file content use:FileRead Fuction & IF_Else. none
ARPFre Posted March 28, 2022 Author Posted March 28, 2022 (edited) #include <Array.au3> #include <File.au3> Local $sFile = "C:\Coisas\TINA\AreaDeTeste\Nova pasta\Original.txt" Local $aPCs _FileReadToArray($sFile, $aPCs) For $i = 1 To $aPCs[0] Local $DelLine = 0 If StringInStr($aPCs[$i], "Julia") Then $DelLine = $i _FileWriteToLine($sFile,$DelLine,"Teste",0) Next 1 hour ago, ad777 said: @ARPFre if you want to check file content use:FileRead Fuction & IF_Else. Yes, @ad777after saving I can. I wanted the routine before, not to save duplicate. creating the script after saving would be a possibility, but it's a bad and slow development. Edited March 28, 2022 by ARPFre
ad777 Posted March 29, 2022 Posted March 29, 2022 @ARPFre you mean like this: #include <Array.au3> #include <File.au3> OnAutoItExitRegister("_exit") Local $sFile = ".\Original.txt" FileCopy($sFile, @TempDir & "\Orginal.txt", 1) Local $Tmp = FileRead(@TempDir & "\Orginal.txt", -1) While 1 if $Tmp = FileRead($sFile, -1) Then ;;;; MsgBox(64, 'Content', 'Repeated!') ;;;; EndIf Sleep(50) WEnd Func _exit() FileDelete(@TempDir & "\Orginal.txt") EndFunc ;==>_exit none
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