Get grouped Dictionary list from a file that has a time and errors then plot the time differences in python
<p>I have this file as below:</p>

<pre><code>Date;Time;Task;Error_Line;Error_Message
03-13-15;08:2123:10;C:LOGINMAN;01073;Web Login Successful from IP Address xxx.xxx.x.xx
03-13-15;05:23:1235;B:VDOM;0906123;Port 123 Device 1012300 Remote 1 1012301 Link Up RP2009
03-13-15;05:23:123123;A:VCOM;0906123;Port 123 Device 1012300 Remote 1 1012301 Link Up RP2009
03-13-15;05:23:123123;B:VDOM;1312325;Port 123 Device 1012300 Remote 1 1012301 Receive Time Error: 2123666 23270 1396 69
03-13-15;05:23:1233;B:VDOM;13372;Port 123 Device 1012300 Remote 1 1012301 Send Time Error: 123123123 1888 1123123123 69
03-13-15;05:23:1233;A:VCOM;1312325;Port 123 Device 1012300 Remote 1 1012301 Receive Time Error: 2123666 23270 1396 69
03-13-15;05:23:1233;A:VCOM;13372;Port 123 Device 1012300 Remote 1 1012301 Send Time Error: 123123123 1888 1123123123 69
03-13-15;05:21:56;B:VDOM;07270;Port 123 Device 1012300 Remote 1 1012301 AT Timer Expired
03-13-15;05:21:56;A:VCOM;07270;Port 123 Device 1012300 Remote 1 1012301 AT Timer Expired
</code></pre>

<p>The desired output should be like that:</p>

<pre><code>D = {'Error_line1': [Time1,Time2,...],'Error_Line2' = [Time1,Time2,..],...}
</code></pre>

<p>I was looking for plotting the differences between or time based on Error_Line. Error_Line in my file occurs different time . I want group times according to Error_Line. I have have no idea if that works for plotting time.</p>

<p>As far as grouping by line number, this should do the trick:</p>

<pre><code>import csv
D = {}
with open('logfile') as f:
    reader = csv.DictReader(f, delimiter=';')
    for row in reader:
        el = row['Error_Line']
        if el not in D:
            D[el] = []  # Initiate an empty list
        D[el].append(row['Time'])
</code></pre>

python numpy matplotlib plot