Orbiter Posted June 28, 2011 Share Posted June 28, 2011 (edited) I have a huge .txt with names (each name begins on a new line) I would like to put into an array. The way I thought of doing this was to write a small program that modifies the existing .txt and adds [0], [1] etc in front of all the names. Problem is that I cannot seem to get the array number in front of the names, they either replace the line, or generates a new line. Snippet: #Include <file.au3> $lines = 1000 $File = FileRead("C:\Users\Administrator\Desktop\text.txt") For $i = 1 to $lines FileWriteLine("C:\Users\Administrator\Desktop\text.txt", "[" & $i &"]") Next I have tried this also with the _FileWriteToLine function. #Include <file.au3> $lines = 1000 $File = FileRead("C:\Users\Administrator\Desktop\text.txt") For $i = 1 to $lines _FileWriteToLine("C:\Users\Administrator\Desktop\text.txt",$i ,"[" & $i &"]") Next Edited June 28, 2011 by Orbiter Link to comment Share on other sites More sharing options...
jaberwacky Posted June 28, 2011 Share Posted June 28, 2011 _FileReadToArray() Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Orbiter Posted June 28, 2011 Author Share Posted June 28, 2011 _FileReadToArray()Won't that put all the names into just one array? Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 28, 2011 Share Posted June 28, 2011 It does not look like you have a FileOpen in your script. Don't forget to open it in write mode. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
jaberwacky Posted June 28, 2011 Share Posted June 28, 2011 "... I would like to put into an array" You used the singular form. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Orbiter Posted June 28, 2011 Author Share Posted June 28, 2011 To clarify: I have a .txt file formatted like this Aarne Aaron Aase Aba Abai Abaoub Abas Abay AbayomiAbaz AbayomiAbazaj I need a macro or script that converts the .txt file into something like this: [0]Aarne [1]Aaron [2]Aba [3]Abai [4]Abaoub Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 28, 2011 Share Posted June 28, 2011 (edited) <br>_FileReadToArray()<br><br>names.txt Aarne Aaron Aase Aba Abai Abaoub Abas Abay AbayomiAbaz AbayomiAbazaj #include <file.au3> #include <array.au3> Local $aNames _FileReadToArray("names.txt",$aNames) _ArrayDisplay($aNames) </array.au3></file.au3> Edited June 28, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Orbiter Posted June 28, 2011 Author Share Posted June 28, 2011 <br>names.txt Aarne Aaron Aase Aba Abai Abaoub Abas Abay AbayomiAbaz AbayomiAbazaj #include <file.au3> #include <array.au3> Local $aNames _FileReadToArray("names.txt",$aNames) _ArrayDisplay($aNames) </array.au3></file.au3> Thank you very much Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 29, 2011 Share Posted June 29, 2011 Well you're welcome, but LaCastiglione posted an hour before I did the function needed.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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