MaCgyver Posted March 6, 2006 Share Posted March 6, 2006 (edited) I am looking on the help file, but can't seem to find where I can append data to a file. What am I overlooking? I basically want to send the data from one file(file x) to another file (file y). File X gets overwritten throughtout the day with new data. Before the data in file X is overwritten I want to send that data to file Y. File Y will be used at the end of the day to create a report. Edited March 6, 2006 by MaCgyver Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 6, 2006 Moderators Share Posted March 6, 2006 I am looking on the help file, but can't seem to find where I can append data to a file. What am I overlooking? Care to try to be a tad bit more specific? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BigDod Posted March 6, 2006 Share Posted March 6, 2006 I am looking on the help file, but can't seem to find where I can append data to a file. What am I overlooking? FileWriteLine appends to a file. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
MaCgyver Posted March 6, 2006 Author Share Posted March 6, 2006 SmoKe N Looking to read from one file and append the data in the file to another file throught the day. BidDog you answered my question. Thanks Link to comment Share on other sites More sharing options...
BigDod Posted March 6, 2006 Share Posted March 6, 2006 SmoKe NLooking to read from one file and append the data in the file to another file throught the day. BidDog you answered my question. ThanksYou are welcome and the name is BigDod.Why is everyone calling me BigDog now, perhaps I should change it Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
kjactive Posted March 6, 2006 Share Posted March 6, 2006 (edited) You have to provide an argument to FileOpen(FileName and Path, mode argument) $ID = FileOpen(File, mode) // open file for writing IF @error Then Return 1 // check for errors FileWriteLine($ID, text) // write text related to the mode tag in fileopen FileClose($ID) // close the file again Modes: 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks). One can seek into specified locations in the text and insert from this point too and offcourse if one sets the read mode one has to use FileReadLine($ID) and not FileWriteLine( but still remember to close the text at the end. It's posible to use FileWriteLine(/ FileReadLine( without the open/close functions but this is just very slow especially with large texts.. kjactive Edited March 6, 2006 by kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc... Link to comment Share on other sites More sharing options...
MaCgyver Posted March 6, 2006 Author Share Posted March 6, 2006 You have to provide an argument to FileOpen(FileName and Path, mode argument)$ID = FileOpen(File, mode) // open file for writingIF @error Then Return 1 // check for errorsFileWriteLine($ID, text) // write text related to the mode tag in fileopenFileClose($ID) // close the file againModes: 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks).One can seek into specified locations in the text and insert from this point too and offcourse if one sets the read mode one has to use FileReadLine($ID) and not FileWriteLine( but still remember to close the text at the end. It's posible to use FileWriteLine(/ FileReadLine( without the open/close functions but this is just very slow especially with large texts..kjactive I basically want to send the data from one file(file x) to another file (file y). File X gets overwritten throughtout the day with new data. Before the data in file X is overwritten I want to send that data to file Y. File Y will be used at the end of the day to create a report. Link to comment Share on other sites More sharing options...
Valuater Posted March 6, 2006 Share Posted March 6, 2006 maybe $data = FileRead($file_x, FileGetSize($file_x)) FileWrite($file_y, $data) 8) Link to comment Share on other sites More sharing options...
MaCgyver Posted March 6, 2006 Author Share Posted March 6, 2006 (edited) maybe$data = FileRead($file_x, FileGetSize($file_x))FileWrite($file_y, $data)8)Before I read what you wrote I tried this, but it pauses for some reason. I'm thinking what you wrote is sort of what I put together, but I will try to make it simpler.$file = FileOpen('c:\scripts\testing2.csv', 0)$file2 = FileOpen('c:\scripts\testing.csv', 1); Check if file opened for reading OKIf $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitEndIf; Read in lines of text until the EOF is reachedWhile 1 $line = FileReadLine($file) FileWriteLine($file2, $line) If @error = -1 Then ExitLoop WendFileClose($file)FileClose($file2) Edited March 6, 2006 by MaCgyver Link to comment Share on other sites More sharing options...
Valuater Posted March 6, 2006 Share Posted March 6, 2006 you error checking needs to be right after the READ $line = FileReadLine($file) If @error = -1 Then ExitLoop 8) Link to comment Share on other sites More sharing options...
MaCgyver Posted March 6, 2006 Author Share Posted March 6, 2006 you error checking needs to be right after the READ$line = FileReadLine($file)If @error = -1 Then ExitLoop8)That was it!! Thanks Link to comment Share on other sites More sharing options...
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