Jump to content
Sign in to follow this  
FireLord

Import from text file

Recommended Posts

FireLord

How do I import words from a text file to an INI. Text file format would be:

word1

word2

word3

...

to an INI format like this:

Key=word1,word2,word3,

Regards,

FireLord


[center]See the Helpfile[/center]
While Alive()
	 DrinkWine();
}
[center][/center]

Share this post


Link to post
Share on other sites
Jex
FireLord

#include <File.au3>
$Key = ""
$Count = _FileCountLines("Test.txt")
For $i = 1 To $Count
    $Text = FileReadLine("Test.txt", $i)
    If $i = 1 Then
        $Key = $Text & ","
    ElseIf $i = $Count Then
        $Key = $Key & $Text
    Else
        $Key = $Key & $Text & ","
    EndIf
Next
FileWrite("Test.ini", "Key=" & $Key)
Thank you so much. This works great!

[center]See the Helpfile[/center]
While Alive()
	 DrinkWine();
}
[center][/center]

Share this post


Link to post
Share on other sites
FireLord

One of the variant:

#include <File.au3>

Dim $TxtArray, $string

_FileReadToArray(@ScriptDir & "\test.txt", $TxtArray)
For $i = 1 To $TxtArray[0]
    $string &= $TxtArray[$i] & ", "
Next

$string = StringTrimRight($string, 2)

IniWrite(@ScriptDir & "\test.ini", "Section", "Key", $string)
Thanks.

[center]See the Helpfile[/center]
While Alive()
	 DrinkWine();
}
[center][/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×