Justin Posted December 12, 2006 Posted December 12, 2006 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?
Xenobiologist Posted December 12, 2006 Posted December 12, 2006 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
Valuater Posted December 12, 2006 Posted December 12, 2006 (edited) maybe... $text = "this" & @CRLF & @LF & "that" MsgBox(64,"test1", $text, 5) $text2 = StringReplace( $text, @CRLF, @CR) $text2 = StringReplace( $text2, @LF, @CR) InputBox("","", $text2) fixed StringReplace( $text2, 8) Edited December 12, 2006 by Valuater
/dev/null Posted December 12, 2006 Posted December 12, 2006 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 *
Valuater Posted December 12, 2006 Posted December 12, 2006 (edited) Why not StringReplace($text,@LF,"") ??CheersKurtwould that replace @CRLF... its not @LF ???fixedStringReplace( $text2,8) Edited December 12, 2006 by Valuater
herewasplato Posted December 12, 2006 Posted December 12, 2006 (edited) FileWrite("test-out.txt", StringReplace(FileRead("test-in.txt"), @LF, ""))oÝ÷ Ù«¢+Ù¥±]É¥Ñ ÅÕ½ÐíÑÍе½ÕйÑáÐÅÕ½Ðì°MÑÉ¥¹IÁ±¡¥±I ÅÕ½ÐíÑÍе¥¸¹ÑáÐÅÕ½Ð줰 I1°1¤¤either way works just fine Edited December 12, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Justin Posted December 12, 2006 Author Posted December 12, 2006 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)
Zedna Posted December 12, 2006 Posted December 12, 2006 (edited) The only one line of AutoIt code can do it for you 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 EDIT: herewasplato & Justin beat me Edited December 12, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
/dev/null Posted December 12, 2006 Posted December 12, 2006 would that replace @CRLF... its not @LF ???fixedStringReplace( $text2,8)no, but that's not what he is asking for: "and remove the LF's to leave just a carriage return"CheersKurt __________________________________________________________(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 *
herewasplato Posted December 12, 2006 Posted December 12, 2006 See what a good post title will bring... lots of help and code. Must be a slow day on the forum...... [size="1"][font="Arial"].[u].[/u][/font][/size]
Justin Posted December 13, 2006 Author Posted December 13, 2006 (edited) Thanks, worked perfectly! Edited December 13, 2006 by Justin
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