Duplikate Problem

  • Hallo,

    ich habe folgendes Problem:
    es gibt eine Liederliste. Hier muß ich nun alle Interpreten
    herausfiltern. Der Interpret sollte aber in der neuen Liste
    nur einmal erscheinen. (Also nur Interpreten, Bands...)

    Beispiel:
    Originalliste

    Zitat

    Dancing Queen;ABBA
    Fernando;ABBA
    Super Trouper;ABBA
    All That She Wants;Ace Of Base
    Aloha Heja He;Achim Reichel

    Die neue Liste sollte nun so aussehen:

    Zitat

    ABBA
    Ace of Base
    Achim Reichel

    Hier mal mein Code (ohne Duplicate...)

    Spoiler anzeigen
    [autoit]


    $Liste = FileOpenDialog("Neue Liste", @ScriptDir, "Songliste (*.txt)")
    $File = FileOpen($Liste, 0)
    $file2 = FileOpen("Interpreten.txt", 1)
    While True
    $Line = FileReadLine($File)
    If @error Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    $Interpret = StringSplit($Line, ";")
    ;MsgBox(0, "Lied", $Interpret[1])
    ;MsgBox(0, "Interpret", $Interpret[2])
    FileWriteLine($file2, $Interpret[2]) ; hier müsste irgendwie überprüft werden ob der Interpret bereits existiert???
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    FileClose($File)
    FileClose($File2)

    [/autoit]

    Hoffe Ihr habt da ne Idee.

    Liebe Grüße
    Ilse ;)

    Einmal editiert, zuletzt von Ilse (10. Mai 2013 um 15:39)

  • Hallo Chesstiger,

    brauch nochmal deine Hilfe.
    Hab das Script mit

    [autoit]


    #include <Array.au3>
    #include <file.au3>

    [/autoit]

    Komm irgendwie nicht weiter. Arrays, da ban ich immer meine Probleme
    $Interpret = StringSplit($Line, ";")
    ist doch bereits ein array?

    Zitat

    Alle Titel erstmal temporär in einem Array speichern


    Würd mich über ein Beispiel freuen, steh etwas auf dem "Schlauch"

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    #include <file.au3>
    $Liste = FileOpenDialog("Neue Liste", @ScriptDir, "Songliste (*.txt)")
    $File = FileOpen($Liste, 0)
    $file2 = FileOpen("Interpreten.txt", 1)
    $sFile = @ScriptDir & "\Interpreten1.txt"
    While True
    $Line = FileReadLine($File)
    If @error Then ExitLoop
    _FileWriteFromArray($sFile, $Interpret[2], -1)
    $Interpret = StringSplit($Line, ";")
    ;MsgBox(0, "Lied", $Interpret[1])
    ;MsgBox(0, "Interpret", $Interpret[2])
    FileWriteLine($file2, $Interpret[2])
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    FileClose($File)
    FileClose($File2)
    FileClose($sFile)

    [/autoit]

    Liebe Grüße
    Ilse :(

  • Spoiler anzeigen
    [autoit]


    #include <File.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $sSongliste = FileOpenDialog("Neue Liste", @ScriptDir, "Songliste (*.txt)")
    $sInterpretFile = "Interpreten.txt"

    [/autoit] [autoit][/autoit] [autoit]

    Local $aSongs, $aInterpreten_UNIQUE
    _FileReadToArray($sSongliste, $aSongs)
    Local $aInterpreten[$aSongs[0]]
    For $i = 1 To $aSongs[0]
    $aInfo = StringSplit($aSongs[$i], ";", 3)
    $aInterpreten[$i - 1] = $aInfo[1]
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $aInterpreten_UNIQUE = _ArrayUnique($aInterpreten)
    _ArrayDisplay($aInterpreten_UNIQUE)

    [/autoit] [autoit][/autoit] [autoit]

    _FileWriteFromArray($sInterpretFile, $aInterpreten_UNIQUE)

    [/autoit]

    Verstanden, wie ich das meinte?
    Mein temporäres Array wird hier automatisch durch _FileReadToArray erzeugt. ^^

    lg

  • Hallo Chesstiger,

    erstmal danke für die Mühe mit mir.

    klappt aber irgendwie nicht.
    $sInterpretFile = "Interpreten.txt"

    ... in dieser txt Datei kommt nichts an.

    _FileWriteFromArray schreibt irgendwie nicht in die txt Datei!

    Liebe Grüße
    Ilse :(

  • Hallo Chesstiger,

    das sind die Meldungen

    [autoit]


    (12) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
    $aInterpreten[$i - 1] = $aInfo[1]
    $aInterpreten[$i - 1] = ^ ERROR

    [/autoit]

    Hier nochmals die Datei die geöffnet wird.
    Ist natürlich wesentlich größes

    Spoiler anzeigen


    Dancing Queen;ABBA
    Fernando;ABBA
    Super Trouper;ABBA
    All That She Wants;Ace Of Base
    Aloha Heja He;Achim Reichel
    Classic;Adrian Ben Gurvitz
    Azzurro;Adriano Celentano
    Take On Me;a-ha
    Felicità;Al Bano & Romina Power
    Spanish Eyes Moon Over Naples;Al Martino
    Year Of The Cat;Al Stewart
    Tu T'en Vas;Alain Barrière & Noelle Cordier
    Don't Answer Me;Alan Parsons Project


    Schade...
    Liebe Grüße Ilse
    :(

  • Ach, wenn's weiter nichts ist. :D

    Spoiler anzeigen
    [autoit]


    #include <File.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $sSongliste = FileOpenDialog("Neue Liste", @ScriptDir, "Songliste (*.txt)")
    $sInterpretFile = "Interpreten.txt"

    [/autoit] [autoit][/autoit] [autoit]

    Local $aSongs, $aInterpreten_UNIQUE
    _FileReadToArray($sSongliste, $aSongs)
    Local $aInterpreten[$aSongs[0]]
    For $i = 1 To $aSongs[0]
    $aInfo = StringSplit($aSongs[$i], ";", 3)
    If UBound($aInfo) <> 2 Then ContinueLoop
    $aInterpreten[$i - 1] = $aInfo[1]
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $aInterpreten_UNIQUE = _ArrayUnique($aInterpreten)
    _ArrayDisplay($aInterpreten_UNIQUE)

    [/autoit] [autoit][/autoit] [autoit]

    _FileWriteFromArray($sInterpretFile, $aInterpreten_UNIQUE)

    [/autoit]

    Dann hast du eine ungültige Zeile ohne ";" dabei gehabt.^^

    lg