Jump to content
Sign in to follow this  
myspacee

Delete row in a text file

Recommended Posts

myspacee

hello to all,

need help.

need to replace a row in my text file :

a
b
c
d
e
f
i
g
h
l
z
z
z
z
z

you see a lot of identical row 'z'

if use _ReplaceStringInFile function replace all 'z'

I know row number in file, is possible to replace that line and no others ?

Thank you for help !

m.

Share this post


Link to post
Share on other sites
Andreik

hello to all,

need help.

need to replace a row in my text file :

a
b
c
d
e
f
i
g
h
l
z
z
z
z
z

you see a lot of identical row 'z'

if use _ReplaceStringInFile function replace all 'z'

I know row number in file, is possible to replace that line and no others ?

Thank you for help !

m.

Try this:

#Include <File.au3>

Func ReplaceInRow($FILE,$ROW,$SEARCH,$REPLACE)
$OPEN = FileOpen($FILE,0)
$LINE = FileReadLine($OPEN,$ROW)
FileClose($OPEN)
$NEW_LINE = StringReplace($LINE,$SSTRING,$RSTRING)
_FileWriteToLine($FILE,$ROW,$NEW_LINE,1)
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites
myspacee

hmmm some problems,

#Include <File.au3>

dim $FILE,$ROW,$SEARCH,$REPLACE,$SSTRING,$RSTRING

$FILE = "list.txt"

ReplaceInRow($FILE,5,"e","find_find_find_find")


Func ReplaceInRow($FILE,$ROW,$SEARCH,$REPLACE)
    $OPEN = FileOpen($FILE,0)
    $LINE = FileReadLine($OPEN,$ROW)
    FileClose($OPEN)
    $NEW_LINE = StringReplace($LINE,$SSTRING,$RSTRING)
    _FileWriteToLine($FILE,$ROW,$NEW_LINE,1)
EndFunc

understand concept but can't able to use...

Share this post


Link to post
Share on other sites
myspacee

solved,

learn to use _FileWriteToLine,

thankyou,

m.

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  

×