Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 06:59

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



werte aus txt file parsen

Discussion on werte aus txt file parsen within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 20
Join Date: Feb 2007
Posts: 3,080
Received Thanks: 4,294
werte aus txt file parsen

moin moin,

wollte mal fragen ob hier wer langeweile hat und mir nen script bastelt welches mir alle werte einer jeden zeile aus einer txt file ausliest und praktischerweise in einem array speichert.

die werte wären von links nach rechts gesehen:
position, name, alter, stärke, frische, ep, tp, awp

txt file sieht so aus.

kknb is offline  
Thanks
1 User
Old 04/09/2011, 21:14   #2
 
TrickGamer's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 487
Received Thanks: 196
nimm doch einfach IniRead() und IniWrite()
TrickGamer is offline  
Old 04/09/2011, 21:57   #3
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
versuchs mal hiermit:
Code:
StringRegExp($content, '([[:graph:]]+)[[:blank:]]*([[:print:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)', 4)
Edit:
da keine antwort kam hier nochmal als vollständiges beispiel:
Code:
$content = FileRead('text.txt')
$parsed = StringRegExp($content, '([[:graph:]]+)[[:blank:]]*([[:print:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)[[:blank:]]*([[:graph:]]+)', 4)
For $z = 0 To UBound($parsed)-1
	$selected = $parsed[$z]
	ConsoleWrite('Item'&$z&':'&@CRLF)
	For $i=1 To UBound($selected)-1
		ConsoleWrite('    '&$selected[$i]&@CRLF)
	Next
Next
output würde dann so aussehen:

natürlich musst dus nich so ausgeben, wollte nur mal zeigen das du so alles sofort in einem einzigen array gespeichert hättest.
lolkop is offline  
Old 04/10/2011, 18:28   #4
 
elite*gold: 20
Join Date: Feb 2007
Posts: 3,080
Received Thanks: 4,294
also im endeffekt hab ichs nun doch recht einfach gelöst, hier mal ein ausschnitt.

Code:
					$CountLines = _FileCountLines($file)
					For $i = 0 To $CountLines
						If $i = 1 Or Mod($i, 9) = 0 Then
							$line = FileReadLine($file, $i + 1)
							If StringInStr($line, "€") Then ContinueLoop
							$prepLine = StringRegExpReplace($line, "	", "/")
							FileWrite($prepedFile, $prepLine & @CRLF)
						EndIf
					Next
					$prepedLines = _FileCountLines($prepedFile)
					For $a = 1 To $prepedLines
						ReDim $Position[$a + 1]
						ReDim $Name[$a + 1]
						ReDim $Alter[$a + 1]
						ReDim $Staerke[$a + 1]
						ReDim $Frische[$a + 1]
						ReDim $Erfahrung[$a + 1]
						ReDim $Training[$a + 1]
						ReDim $AWP[$a + 1]
						$line = FileReadLine($prepedFile, $a)
						$splittedString = StringSplit($line, "/")
						$Position[$a] = $splittedString[6]
						$Name[$a] = $splittedString[7]
						$Alter[$a] = $splittedString[8]
						$Staerke[$a] = $splittedString[10]
						$Frische[$a] = $splittedString[11]
						$Erfahrung[$a] = $splittedString[14]
						$Training[$a] = $splittedString[15]
						$AWP[$a] = $splittedString[16]
					Next
sry wegen der formatierung ist halt mitten aus dem script kopiert.
im endeffekt hab ich einfach die tabs durch "/" ersetzt und dann via stringsplit gesplittet.
kknb is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
anyone post here the file of editing file.. the .edf file
07/13/2013 - RF Online - 3 Replies
please post here... so that i can download again.. i guess the old one thread was gone.. i've been search for an hour in this section.. but i can't see it... thanks..
[LUA] String parsen.
12/22/2010 - General Coding - 5 Replies
Hallo , ich würde gern nach einem string suchen und den dann aufteilen das wenn ich z.b :collect Saroniterz 9 eingebe das er dann das Saroniterz und die anzahl rauspickt und ich die weiterverwenden kann , weiß einer vll wie das geht?
How to open mesh file and anim file(dekaron).PLZ~
02/15/2010 - Dekaron Private Server - 11 Replies
How to open mesh file and anim file(dekaron).PLZ~



All times are GMT +2. The time now is 06:59.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.