User defined function _FileWriteToLine($sFilePath,
$iLine, $sText [, $bOverWrite = False]) can be used for inserting 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")
;Insert a new line of data to line 3. The existing line will be shifted to next line.
_FileWriteToLine("c:\AutomationDevelopers\temp.csv", 3, "Sophia, 15")
; 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")
;Insert a new line of data to line 3. The existing line will be shifted to next line.
_FileWriteToLine("c:\AutomationDevelopers\temp.csv", 3, "Sophia, 15")
- AutoIt - Write data to a specific line in a file (overwrite the existing line)
- 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