[R] Lire un fichier txt
Posté : sam. 01 nov. 2008 13:52
Bonjour, je ne trouve pas dans la doc comment lire un fichier texte pour récupérer des donner précise a l'interieur, pouriez vous m'indiquer un tuto ?
Communauté Francophone AutoIt
https://www.autoitscript.fr/forum/
Code : Tout sélectionner
$vrFchConf = FileOpen($vrLunnaConf, 0)
While 1
$chars = FileRead($vrFchConf, 1)
MsgBox(0, "Char read:", $chars)
Wend
Code : Tout sélectionner
$file = FileOpen("test.txt", 0)
; Vérifie si l'ouverture du fichier en OK pour la lecture
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
; Lit un caractère à la fois jusque la fin (oef) et attend
While 1
$chars = FileRead($file, 1)
If @error = -1 Then ExitLoop
MsgBox(0, "Char read:", $chars)
Wend
FileClose($file)
Code : Tout sélectionner
$Lecture = "Montext.txt"
Lire($lecture)
Func Lire ( $Fichier )
Return FileRead ( $Fichier , FileGetSize ( $Fichier ) )
EndFunc
Code : Tout sélectionner
$file = FileOpen("test.txt", 0)
; Vérifie si l'ouverture du fichier en OK pour la lecture
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
MsgBox(0, "Line read:", $line)
Wend
FileClose($file)
Code : Tout sélectionner
$file="text.txt"
$read = FileRead($file)
$line = StringSplit($read, @CR)
For $i = 1 To $line[0]
$var = FileReadLine($file, $i)
Next
Code : Tout sélectionner
$vrFchConf = FileOpen($vrLunnaConf, 0)
While 1
$chars = FileReadLine($vrFchConf, 1)
MsgBox(0, "Char read:", $chars)
Wend
FileClose($vrFchConf)
Code : Tout sélectionner
$vrFchConf = FileOpen($vrLunnaConf, 0)
While 1
$chars = FileReadLine($vrFchConf)
If @error then ExitLoop
MsgBox(0, "Char read:", $chars)
Wend
FileClose($vrFchConf)
Code : Tout sélectionner
repCible=C:\Documents and Settings\lunnatick\Bureau
Code : Tout sélectionner
$vrFchConf = FileOpen($vrLunnaConf, 0)
While 1
$chars = FileReadLine($vrFchConf)
If @error Then ExitLoop
;On verifie si la lettre : est dans la ligne
If StringInStr($chars,":",1) Then
;Ici on découpe la ligne et on récupere la deuxi!me partie
$chars = stringsplit($chars,":")
$chars = $chars[2]
EndIf
MsgBox(0, "Char read:", $chars)
Wend
FileClose($vrFchConf)
Code : Tout sélectionner
$vrFchConf = FileOpen($vrLunnaConf, 0)
While 1
$vrLignConf = FileReadLine($vrFchConf)
If @error then ExitLoop
$vrChmRepCiblConf = StringSplit($vrLignConf,"=")
$vrRepCible = $vrChmRepCiblConf[2]
Wend
FileClose($vrFchConf)