Jump to content

Recommended Posts

Posted

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

Posted (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 by ARPFre
Posted

@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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...