Paarungen auflisten

  • Moin Moin.

    Ich habe 365 Paarungen, die ich in eine CSV Datei habe.
    Aufbau: Nr. | "Teil-A | Teil-B
    Ich suche jetzt eine Möglichkeit der Auflistung, wie oft eine Teil-A/Teil-B Paarung vorkommt und
    unter welcher Nummer ich diese wieder finde.
    Es gibt z. B. die Paarung 9 und 4 und diese mehr als wenige male. Genauso die Paarung 10 und 5 und so weiter. ;)
    Ausgabe stellt ich mir dann vor:
    94=2,15,29,....
    105=3,16, 30, ...

    Spoiler anzeigen
    [autoit]


    Nr.;Teil-A;Teil-B
    1;0;0
    2;9;4
    3;10;5
    4;0;0
    5;1;6
    6;2;7
    7;3;8
    8;4;9
    9;5;10
    10;0;0
    11;0;0
    12;6;1
    13;7;2
    14;8;3
    15;9;4
    16;10;5
    17;0;0
    18;0;0
    19;1;6
    20;2;7
    21;3;8
    22;4;9
    23;5;10
    24;0;0
    25;0;0
    26;6;1
    27;7;2
    28;8;3
    29;9;4
    30;10;5
    31;0;0
    32;0;0
    33;1;6
    34;2;7
    35;3;8
    36;4;9
    37;5;10
    38;0;0
    39;0;0
    40;6;1
    41;7;2
    42;8;3
    43;9;4
    44;10;5
    45;0;0
    46;0;0
    47;1;6
    48;2;7
    49;3;8
    50;4;9
    51;5;10
    52;0;0
    53;0;0
    54;6;1
    55;7;2
    56;8;3
    57;9;4
    58;10;5
    59;0;0
    60;0;0
    61;1;6
    62;2;7
    63;3;8
    64;4;9
    65;5;10
    66;0;0
    67;0;0
    68;6;1
    69;7;2
    70;8;3
    71;9;4
    72;10;5
    73;0;0
    74;0;0
    75;1;6
    76;2;7
    77;3;8
    78;4;9
    79;5;10
    80;0;0
    81;0;0
    82;6;1
    83;7;2
    84;8;3
    85;9;4
    86;10;5
    87;0;6
    88;0;0
    89;1;7
    90;2;8
    91;3;9
    92;4;10
    93;0;0
    94;5;0
    95;0;0
    96;0;0
    97;6;1
    98;7;2
    99;8;3
    100;9;4
    101;10;5
    102;0;0
    103;1;6
    104;2;7
    105;3;8
    106;4;9
    107;5;10
    108;0;0
    109;0;0
    110;6;1
    111;7;2
    112;8;3
    113;9;4
    114;10;5
    115;0;6
    116;0;0
    117;1;7
    118;2;8
    119;3;9
    120;4;10
    121;0;0
    122;5;0
    123;0;0
    124;6;1
    125;7;2
    126;8;3
    127;9;4
    128;10;5
    129;0;0
    130;0;0
    131;1;6
    132;2;7
    133;3;8
    134;0;0
    135;4;9
    136;5;10
    137;0;0
    138;6;1
    139;7;2
    140;8;3
    141;9;4
    142;10;5
    143;0;0
    144;0;0
    145;0;0
    146;1;6
    147;2;7
    148;3;8
    149;4;9
    150;5;10
    151;0;0
    152;6;1
    153;7;2
    154;8;3
    155;9;4
    156;10;5
    157;0;0
    158;0;0
    159;1;6
    160;2;7
    161;3;8
    162;4;9
    163;5;10
    164;0;0
    165;0;0
    166;6;1
    167;7;2
    168;8;3
    169;9;4
    170;10;5
    171;0;0
    172;0;0
    173;1;6
    174;2;7
    175;3;8
    176;4;9
    177;5;10
    178;0;0
    179;0;0
    180;6;1
    181;7;2
    182;8;3
    183;9;4
    184;10;5
    185;0;0
    186;0;0
    187;1;6
    188;2;7
    189;3;8
    190;4;9
    191;5;10
    192;0;0
    193;0;0
    194;6;1
    195;7;2
    196;8;3
    197;9;4
    198;10;5
    199;0;0
    200;0;0
    201;1;6
    202;2;7
    203;3;8
    204;4;9
    205;5;10
    206;0;0
    207;0;0
    208;6;1
    209;7;2
    210;8;3
    211;9;4
    212;10;5
    213;0;0
    214;0;0
    215;1;6
    216;2;7
    217;3;8
    218;4;9
    219;5;10
    220;0;0
    221;0;0
    222;6;1
    223;7;2
    224;8;3
    225;9;4
    226;10;5
    227;0;0
    228;0;0
    229;1;6
    230;2;7
    231;3;8
    232;4;9
    233;5;10
    234;0;0
    235;0;0
    236;6;1
    237;7;2
    238;8;3
    239;9;4
    240;10;5
    241;0;0
    242;0;0
    243;1;6
    244;2;7
    245;3;8
    246;4;9
    247;5;10
    248;0;0
    249;0;0
    250;6;1
    251;7;2
    252;8;3
    253;9;4
    254;10;5
    255;0;0
    256;0;0
    257;1;6
    258;2;7
    259;3;8
    260;4;9
    261;5;10
    262;0;0
    263;0;0
    264;6;1
    265;7;2
    266;8;3
    267;9;4
    268;10;5
    269;0;0
    270;0;0
    271;1;6
    272;2;7
    273;3;8
    274;4;9
    275;5;10
    276;0;0
    277;0;0
    278;6;1
    279;7;2
    280;8;3
    281;9;4
    282;10;5
    283;0;0
    284;0;0
    285;1;6
    286;2;7
    287;3;8
    288;4;9
    289;5;10
    290;0;0
    291;0;0
    292;6;1
    293;7;2
    294;8;3
    295;9;4
    296;10;5
    297;0;0
    298;0;0
    299;1;6
    300;2;7
    301;3;8
    302;4;9
    303;5;10
    304;0;0
    305;0;0
    306;6;1
    307;7;2
    308;8;3
    309;9;4
    310;10;5
    311;0;0
    312;0;0
    313;1;6
    314;2;7
    315;3;8
    316;4;9
    317;5;10
    318;0;0
    319;0;0
    320;6;1
    321;7;2
    322;8;3
    323;9;4
    324;10;5
    325;0;0
    326;0;0
    327;1;6
    328;2;7
    329;3;8
    330;4;9
    331;5;10
    332;0;0
    333;0;0
    334;6;1
    335;7;2
    336;8;3
    337;9;4
    338;10;5
    339;0;0
    340;0;0
    341;1;6
    342;2;7
    343;3;8
    344;4;9
    345;5;10
    346;0;0
    347;0;0
    348;6;1
    349;7;2
    350;8;3
    351;9;4
    352;10;5
    353;1;6
    354;0;0
    355;2;7
    356;3;8
    357;4;9
    358;5;10
    359;0;0
    360;0;0
    361;0;0
    362;6;1
    363;7;2
    364;8;3
    365;9;4

    [/autoit]

    Hat jemand eine Idee?

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Spoiler anzeigen
    [autoit]

    $hFile = FileOpen("Test.csv")
    If @error Then Exit

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

    $dic_Paare = ObjCreate("Scripting.Dictionary")

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

    ; Dictionary mit Paaren als Schlüssel und Nummern als Werte:
    FileReadLine($hFile) ; erste Zeile überspringen (Überschrift)
    Do
    $s_Line = FileReadLine($hFile)
    If @error Then ExitLoop

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

    $a_Split = StringSplit($s_Line, ";", 2)
    If UBound($a_Split) < 3 Then ContinueLoop

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

    $key = $a_Split[1] & $a_Split[2]
    $dic_Paare($key) = $dic_Paare.Exists($key) ? $dic_Paare($key) & "," & $a_Split[0] : $a_Split[0]
    Until 0
    FileClose($hFile)

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

    ; Dictionary wieder auslesen:
    For $i in $dic_Paare.Keys()
    ConsoleWrite($i & "=" & $dic_Paare($i) & @CRLF)
    Next

    [/autoit]

    Ein Dictionary ist hierfür ideal, da man hier einem Schlüsselwert (deine 94) dynamisch Werte zuweisen möchte.

  • so?

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    $inhalt = FileRead("paarungen.csv")

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

    $temp = StringSplit($inhalt, @CRLF, 3) ;zeilenweise

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

    Dim $array[UBound($temp) + 2][3] ;CSV in array

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

    For $i = 1 To UBound($temp) - 1 ;kopfzeile nicht verwenden
    $temp2 = StringSplit($temp[$i], ";", 3)
    $array[$i][0] = $temp2[0]
    $array[$i][1] = $temp2[1] & ";" & $temp2[2]
    Next

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

    _ArraySort($array, 0, 0, 0, 1) ;
    While $array[0][0] = "" ;leere Zeilen löschen
    _ArrayDelete($array, 0)
    WEnd
    _arraydisplay($array)

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

    $anzahl_gesamt = 1
    $nummern = "Paar " & $array[0][1] & " hat Nummern: " & $array[0][0]
    $aktuelles_Paar = $array[0][1]
    For $i = 1 To UBound($array) - 1 ;alle paare durchlaufen und nummern aufzählen
    $paar = $array[$i][1]
    $nr = $array[$i][0]
    $anzahl_gesamt += 1
    If $paar = $aktuelles_Paar Then ;paare gleich?
    $nummern = $nummern & ";" & $nr ;nummer anfügen
    Else ;neues Paar gefunden
    $aktuelles_Paar = $paar
    $nummern = $nummern & @CRLF & @CRLF
    $nummern &= "Paar " & $array[$i][1] & " hat Nummern: " & $array[$i][0]
    EndIf

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

    Next

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

    MsgBox(0, $anzahl_gesamt, $nummern)

    [/autoit]

    @AspirinJunkie,
    und sogar noch sortiert, seeehr nice :thumbup:

    //EDIT
    Gehirnkrampf gelöst und Script angepasst

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    3 Mal editiert, zuletzt von Andy (10. Dezember 2014 um 18:12)

  • Die beiden Lösungen sind: SPITZE !!!
    VIELEN DANK !!!

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl