Jump to content

Removing @LF's from a txt file


Justin
 Share

Recommended Posts

I am working on a script and would like to add a feature that parses through a text file that has a CR & LF at the end of each line, and remove the LF's to leave just a carriage return there. Is there an easy way of doing this?

Hi,

did you try StringReplace?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

maybe...

$text = "this" & @CRLF & @LF & "that"

MsgBox(64,"test1", $text, 5)

$text2 = StringReplace( $text, @CRLF, @CR)
$text2 = StringReplace( $text, @LF, @CR)

InputBox("","", $text2)

8)

Why not StringReplace($text,@LF,"") ??

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

FileWrite("test-out.txt", StringReplace(FileRead("test-in.txt"), @LF, ""))oÝ÷ Ù«­¢+Ù¥±]É¥Ñ ÅÕ½ÐíÑÍе½ÕйÑáÐÅÕ½Ðì°MÑÉ¥¹IÁ±¡¥±I ÅÕ½ÐíÑÍе¥¸¹ÑáÐÅÕ½Ð줰
I1°1¤¤
either way works just fine

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Alright, I need a way to parse each line in the document. Assuming the document was called CRLF.txt and is in the same directory as the script, it needs to parse the entire 500 lines of the txt file, and either just take out each of the @lf's, or rewrite the document without them while maintaining the same formatting.

The following is what I have as sort of a test script, but all this does is return me a blank new txt file.

$file = FileOpen("CRLF.txt",0)
$string = FileRead($file)
FileClose($file)

$newString = StringReplace($string,@CRLF,@CR)
$file = FileOpen("crlf.txt",2)
FileWrite($file,$newString)
FileClose($file)
Link to comment
Share on other sites

The only one line of AutoIt code can do it for you :D

FileWrite('output_file.txt', StringReplace(FileRead('input_file.txt'), @CRLF, @CR))

Of course this is not well readable and without error checking just for demostrate power of AutoIt :P

EDIT: herewasplato & Justin beat me

Edited by Zedna
Link to comment
Share on other sites

would that replace @CRLF... its not @LF ???

fixed

StringReplace( $text2,

8)

no, but that's not what he is asking for: "and remove the LF's to leave just a carriage return"

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
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
 Share

  • Recently Browsing   0 members

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