User defined function _FileWriteToLine($sFilePath,
$iLine, $sText [, $bOverWrite = False]) can be used for writing data to a
specific line. The OverWrite flag will decide on whether to overwrite the
existing line or not. The default is False (No overwrite). The function is
defined in the include file File.au3 and it is very useful when there is
requirement for updating CSV files etc.
Example:
#include <File.au3>
; Assign the file path to a variable
Local $sFilePath = "C:\AutomationDevelopers\temp.csv"
;Write a set of lines for demonstration
FileWriteLine($sFilePath, "Name, Age")
FileWriteLine($sFilePath, "David, 12")
FileWriteLine($sFilePath, "Gloria, 14")
FileWriteLine($sFilePath, "Isaac, 13")
;Write data to line 3 by replacing the existing line
_FileWriteToLine("c:\AutomationDevelopers\temp.csv", 3, "Gloria - Replaced, 15", True)
; Assign the file path to a variable
Local $sFilePath = "C:\AutomationDevelopers\temp.csv"
;Write a set of lines for demonstration
FileWriteLine($sFilePath, "Name, Age")
FileWriteLine($sFilePath, "David, 12")
FileWriteLine($sFilePath, "Gloria, 14")
FileWriteLine($sFilePath, "Isaac, 13")
;Write data to line 3 by replacing the existing line
_FileWriteToLine("c:\AutomationDevelopers\temp.csv", 3, "Gloria - Replaced, 15", True)
- AutoIt - Insert data to a specific line in a file
- AutoIt - Write a line of text to a file
- AutoIt - Write data to a file
- AutoIt - Read data from a file to an array
- AutoIt - Read a specific line of data from a file
- AutoIt - Read data from a file
- AutoIt - Open a file for read/ write operations
Interesting? Share and Let Others Know.
Post a Comment