Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 07:54

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

Advertisement



Textdatei mit komma-trennung auflösen

Discussion on Textdatei mit komma-trennung auflösen within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2010
Posts: 5
Received Thanks: 0
Textdatei mit komma-trennung auflösen

Zum einen entschuldigung wenn es dazu schon ein thread gibt, ich habe ihn nicht gefunden.

Ich habe folgendes Problem. Ich habe eine Listbox die so aufgebaut
ist.

$ListView1 = GUICtrlCreateListView("Barcode|EAN|Zeit|Datum|Gesc häft|Ware|Kategorie|Stück|Einzelpreis", 8, 224, 746, 342)

In der Textdatei stehen die werte zu den "Posten" mit komma trennung wie bekomme ich die Daten in die jeweilige Spalte ?

also so:

barcode,ean,zeit,datum,...

Leider kann ich die kommas nicht verhindern da diese Textdatei von einem Anderen Programm erstellt wird.

Die Textdatei an sich einlesen ist klar,
In die Textdatei Schreiben auch, aber die blöden komma-trennungen bekomme ich nicht aufgelöst.

LG flummi1988
Flummi1988 is offline  
Old 03/14/2012, 15:25   #2
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Verwende .
jacky919 is offline  
Thanks
1 User
Old 03/14/2012, 15:45   #3
 
elite*gold: 0
Join Date: Nov 2010
Posts: 5
Received Thanks: 0
Also wenn ich es richtig verstehe theoretisch so ?

$file = FileOpen("liste.txt", 0)
$data = StringSplit(FileReadLine($file), ",")
FileClose($file)

hm. danke erstmal.

muss ich dann die $data direkt der listview übergeben oder gehört da noch ein zwischen schritt zu ? und egal welcher der beiden möglichkeiten wie ?

das sieht jetzt in der au3 so aus

#include <GUIConstants.au3>

#NoTrayIcon
$Form1 = GUICreate("Barcodelister", 759, 606, 201, 55)
$ListView1 = GUICtrlCreateListView("Barcode|EAN|Zeit|Datum|Gesc häft|Ware|Kategorie|Stück|Einzelpreis", 8, 224, 746, 342)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
GUICtrlSendMsg(-1, 0x101E, 2, 60)
GUICtrlSendMsg(-1, 0x101E, 3, 60)
GUICtrlSendMsg(-1, 0x101E, 4, 150)
GUICtrlSendMsg(-1, 0x101E, 5, 120)
GUICtrlSendMsg(-1, 0x101E, 6, 80)
GUICtrlSendMsg(-1, 0x101E, 7, 50)
GUICtrlSendMsg(-1, 0x101E, 8, 70)
$file = FileOpen("liste.txt", 0)
$data = StringSplit(FileReadLine($file), ",")
FileClose($file)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Flummi1988 is offline  
Old 03/14/2012, 16:11   #4
 
Croco™'s Avatar
 
elite*gold: 235
Join Date: Jan 2012
Posts: 920
Received Thanks: 377
Mit einer For Schleife musst du jetzt jedes gefundene Element des Arrays der ListView übergeben.
GuiCtrlCreateListViewItem ist glaube ich der Befehl dazu.
Croco™ is offline  
Old 03/14/2012, 16:32   #5
 
elite*gold: 0
Join Date: Nov 2010
Posts: 5
Received Thanks: 0
For übergabe

Quote:
Originally Posted by ©ⓡⓞ©ⓞ View Post
Mit einer For Schleife musst du jetzt jedes gefundene Element des Arrays der ListView übergeben.
GuiCtrlCreateListViewItem ist glaube ich der Befehl dazu.
Da stehe ich jetzt ganz auf dem Schlauch.
Wie müsste ich dies in meinem falle anstellen ?
Flummi1988 is offline  
Old 03/14/2012, 17:55   #6

 
Njahs's Avatar
 
elite*gold: 574
Join Date: Nov 2010
Posts: 2,498
Received Thanks: 726
Code:
$StringSplit = FileOpen($File)

If isArray($StringSplit)
    For $i = 1 to UBound($StringSplit)
        GuiCtrlSetData($Listbox,$StringSplit[$i])
    Next
Endif
Wenn das nicht funktioniert (Wegen listview) dann probier das hier:

Code:
Global $Variable 
$StringSplit = FileOpen($File)

If isArray($StringSplit)
    For $i = 1 to UBound($StringSplit)
        GuiCtrlCreateListViewItem($StringSplit[$i],$ListView)
    Next
Endif
Njahs is offline  
Old 03/14/2012, 19:32   #7


 
Lawliet's Avatar
 
elite*gold: 2
Join Date: Jul 2009
Posts: 14,456
Received Thanks: 4,685
Quote:
Originally Posted by Njahs View Post
Code:
$StringSplit = FileOpen($File)

If isArray($StringSplit)
    For $i = 1 to UBound($StringSplit)
        GuiCtrlSetData($Listbox,$StringSplit[$i])
    Next
Endif
Wenn das nicht funktioniert (Wegen listview) dann probier das hier:

Code:
Global $Variable 
$StringSplit = FileOpen($File)

If isArray($StringSplit)
    For $i = 1 to UBound($StringSplit)
        GuiCtrlCreateListViewItem($StringSplit[$i],$ListView)
    Next
Endif
Das erste Feld von dem Array enthält die Anzahl der Strings Also einfach eine For schleife mit $i = 1 to Array[0]
For $iArray = 1 to Array[0] Step 1
GuiCtrlCreateListViewItem($Array[$i],$ListView)
Next
Lawliet is offline  
Old 03/14/2012, 20:15   #8
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
nur das FileOpen ohnehin kein array ausgiebt? o0
lolkop is offline  
Old 03/14/2012, 20:25   #9

 
Njahs's Avatar
 
elite*gold: 574
Join Date: Nov 2010
Posts: 2,498
Received Thanks: 726
Quote:
Originally Posted by lolkop View Post
nur das FileOpen ohnehin kein array ausgiebt? o0
Ah, mist! fail...
mein's so:


Code:
$StringSplit = StringSplit(FileRead($File),',')

If isArray($StringSplit)
    For $i = 1 to UBound($StringSplit)
        GuiCtrlSetData($Listbox,$StringSplit[$i])
    Next
Endif
Wenn das nicht funktioniert (Wegen listview) dann probier das hier:

Code:
Global $Variable 
$StringSplit = StringSplit(FileRead($File),',')

If isArray($StringSplit)
    For $i = 1 to UBound($StringSplit)
        GuiCtrlCreateListViewItem($StringSplit[$i],$ListView)
    Next
Endif
Njahs is offline  
Old 03/14/2012, 20:35   #10
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
FileOpen gibt auch nicht den Text zurück, sondern ein Handle der Datei.
jacky919 is offline  
Old 03/29/2012, 09:42   #11
 
elite*gold: 0
Join Date: Nov 2010
Posts: 5
Received Thanks: 0
letze frage

Ich habe jetzt länger dran versucht herumzuwerkeln

aber setze ich das ganze in die case $listview
oder wohin muss die for schleife ?

Weil ich würde es theoretisch so machen funzt nur net.

#include <GUIConstants.au3>

#NoTrayIcon
$Form1 = GUICreate("Barcodelister", 759, 606, 201, 55)
$ListView1 = GUICtrlCreateListView("Barcode|EAN|Zeit|Datum|Gesc häft|Ware|Kategorie|Stück|Einzelpreis", 8, 224, 746, 342)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
GUICtrlSendMsg(-1, 0x101E, 2, 60)
GUICtrlSendMsg(-1, 0x101E, 3, 60)
GUICtrlSendMsg(-1, 0x101E, 4, 150)
GUICtrlSendMsg(-1, 0x101E, 5, 120)
GUICtrlSendMsg(-1, 0x101E, 6, 80)
GUICtrlSendMsg(-1, 0x101E, 7, 50)
GUICtrlSendMsg(-1, 0x101E, 8, 70)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $ListView1
$file = FileOpen("liste.txt", 0)
$data = StringSplit(FileReadLine($file), ",")
Global $Variable
$StringSplit = StringSplit(FileRead($File),',')

If isArray($StringSplit)
For $i = 1 to UBound($StringSplit)
GuiCtrlCreateListViewItem($StringSplit[$i],$ListView)
Next
Endif
FileClose($file)
Exit
EndSwitch
WEnd

stehe da wo ich am 14.03. auch stand

Erschlagt mich bitte ........ ;-)
Flummi1988 is offline  
Old 03/29/2012, 10:48   #12
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
Quote:
Originally Posted by Flummi1988 View Post
#include <GUIConstants.au3>

#NoTrayIcon
$Form1 = GUICreate("Barcodelister", 759, 606, 201, 55)
$ListView1 = GUICtrlCreateListView("Barcode|EAN|Zeit|Datum|Gesc häft|Ware|Kategorie|Stück|Einzelpreis", 8, 224, 746, 342)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
GUICtrlSendMsg(-1, 0x101E, 2, 60)
GUICtrlSendMsg(-1, 0x101E, 3, 60)
GUICtrlSendMsg(-1, 0x101E, 4, 150)
GUICtrlSendMsg(-1, 0x101E, 5, 120)
GUICtrlSendMsg(-1, 0x101E, 6, 80)
GUICtrlSendMsg(-1, 0x101E, 7, 50)
GUICtrlSendMsg(-1, 0x101E, 8, 70)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Case $ListView1
$file = FileOpen("liste.txt", 0)
$data = StringSplit(FileReadLine($file), ",")
Global $Variable
$StringSplit = StringSplit(FileRead($File),',')

If isArray($StringSplit) <--- If ohne Then?
For $i = 1 to UBound($StringSplit)
GuiCtrlCreateListViewItem($StringSplit[$i],$ListView) <--- $ListView?
Next
Endif
FileClose($file)
Exit
EndSwitch
WEnd
es reicht in der regel auch einfach mal in scite zu schauen, was du für syntaxfehler eingebaut hast... sobald du F5 drückst, zeigt dir der debugger sofort alle fehler an.
lolkop is offline  
Old 03/29/2012, 17:39   #13
 
elite*gold: 0
Join Date: Nov 2010
Posts: 5
Received Thanks: 0
Also ich habe es jetzt so abgeändert. Das Programm selber Startet auch,
aber wieso kommt die listview ausgabe nicht zustande ?

hinterlege hier nun mal die Textdatei und das script

-liste.txt-
9876543,21,0:00,01.01.01,xyz,xyz,test,5,15

-Listview.au3-

#include <GUIConstants.au3>

#NoTrayIcon
$Form1 = GUICreate("Barcodelister", 759, 606, 201, 55)
$ListView1 = GUICtrlCreateListView("Barcode|EAN|Zeit|Datum|Gesc häft|Ware|Kategorie|Stück|Einzelpreis", 8, 224, 746, 342)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
GUICtrlSendMsg(-1, 0x101E, 2, 60)
GUICtrlSendMsg(-1, 0x101E, 3, 60)
GUICtrlSendMsg(-1, 0x101E, 4, 150)
GUICtrlSendMsg(-1, 0x101E, 5, 120)
GUICtrlSendMsg(-1, 0x101E, 6, 80)
GUICtrlSendMsg(-1, 0x101E, 7, 50)
GUICtrlSendMsg(-1, 0x101E, 8, 70)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ListView1
$file = FileOpen("liste.txt", 0)
Global $Variable
$StringSplit = StringSplit(FileRead($File),',')

If Then isArray($StringSplit)
For $i = 1 to UBound($StringSplit)
GuiCtrlCreateListViewItem($StringSplit[$i],$ListView1)
Next
FileClose($file)
Exit
EndSwitch
WEnd

Ich habe mir jetzt auch schon mehrfach das iniread und listview verfahren angeschaut aber dahinter komme ich nicht.
Flummi1988 is offline  
Old 03/29/2012, 18:37   #14
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
lies dir docheinmal bitte die autoit grundlagen durch.

kleiner tipp am rande, denk mal darüber nach, was dein script da macht.
If (zu deutsch "wenn"), und Then (zu deutsch "dann"), direkt nacheinander nutzen macht natürlich niemals sinn...

ein einfaches grundwissen über grammatik sollte reichen, um einzusehen, das ein satz so aufgebaut wird:
Code:
Wenn <dieser Ausdruck gilt> Dann <passiert das folgende>
und nicht etwa so:
Code:
Wenn Dann <dieser Ausdruck gilt> <passiert das folgende>
lolkop is offline  
Old 03/30/2012, 02:01   #15
 
aj1987's Avatar
 
elite*gold: 1003
Join Date: Feb 2010
Posts: 791
Received Thanks: 709
Auch wenn du darauss nun nix lernst...
hier die lösung:

Code:
#include <GUIConstants.au3>
#include <File.au3>

Global $file = "test.txt"
Global $zeilen = _FileCountLines($file)
Global $dump
Global $file_string[$zeilen]

#NoTrayIcon
$Form1 = GUICreate("Barcodelister", 759, 606, 201, 55)
$ListView1 = GUICtrlCreateListView("Barcode|EAN|Zeit|Datum|Geschäft|Ware|Kategorie|Stück|Einzelpreis", 8, 224, 746, 342)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
GUICtrlSendMsg(-1, 0x101E, 2, 60)
GUICtrlSendMsg(-1, 0x101E, 3, 60)
GUICtrlSendMsg(-1, 0x101E, 4, 150)
GUICtrlSendMsg(-1, 0x101E, 5, 120)
GUICtrlSendMsg(-1, 0x101E, 6, 80)
GUICtrlSendMsg(-1, 0x101E, 7, 50)
GUICtrlSendMsg(-1, 0x101E, 8, 70)

For $i = 1 To $zeilen
	$file_string[$i - 1] = FileReadLine($file, $i)
	$dump = StringReplace($file_string[$i - 1], ",", "|")
	GUICtrlCreateListViewItem($dump, $ListView1)
Next

GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd
Bedank dich wenn ich dir geholfen hab...
aj1987 is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Teilen mit Komma :P
01/25/2011 - Main - 9 Replies
Huhu *hust* Ja, finde in google nicht was wirkliches. Schreibe morgen ne Mathe Arbeit und ja, ich kann immer noch net mit Komma teilen, also zb. x,xx : x,xx kann ich. Aber zb. x,xx : xxx zb. so eine Aufgabe: 19,99 : 100 = ? Mit den Taschenrechner, ist es einfach die Lösungen zu finden. Kann mir jemand helfen bz. sagen, wie man so rechnet.
Komma & Apostrophe im Link ?!
01/17/2011 - AutoIt - 7 Replies
Hey Leute, habe nen Problem: <td><div style="margin-left:76px; margin-top:135px;"> 20 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 27 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; 27...
Komma im namen ???
05/09/2010 - WarRock - 2 Replies
Hey ich hab auf niderlande server gespielt und dan hab ich das gesehen : Imageshack - screenshot084t.jpg (der erste aus meinem team) Weiß einer wie man das machen kann ??
Die Trennung vom Netz Problem LC
02/13/2010 - Last Chaos - 0 Replies
ciao a tutti sono italiano e gioco nella versione USA di LC. premetto che non mi intendo di trainer, cheat e hack. Pero se ho capito bene, il problema della disconnessione durante l'uso del trainer non e dovuta a un mal funzionamento del trainer e neanche del sovraccarico dei server, ma al nuovo sistema di protezione che hanno attivato dopo il rilascio delle 4 nuove patch. il nuovo sistema di protezione funziona che, il server rileva l'ip dell'account che utulizza il trainer e dopo pochi...



All times are GMT +1. The time now is 07:55.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.