html in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nonemsludo
    New Member
    • Apr 2010
    • 15

    html in python

    Write a python function which reads and processes the data, and, for each datum, if the bytes uploaded value is greater than 50% of the bytes downloaded value in that interval, your program should keep a record of that machine. At the end of processing, the program should print out all such unique machines (by MAC address – each computer should appear once in the output), as well as the number of times the above condition was true for that machine (i.e. how many times during the entire period that it uploaded “too much” data). the output should be in HTML table format.
    Attached Files
  • Nonemsludo
    New Member
    • Apr 2010
    • 15

    #2
    Html in python

    Code:
    def data():
            f = open("C:\Users\user\Desktop\data-transfers.txt","r")
            w = open("C:\Users\user\Desktop\data-transfers.html","w")
            w.write('<html><head><title>Table showing MAC addresses of Computers with unusual Activity</title></head>\n')
            w.write('<body><table border = 2><tr><th>Mac Address</th><th>Number of times unusual activity noticed</th></tr>\n')
            i = 1
            d = dict()
            x = f.readlines()
            for line in x:
                    t = line.split()
                    p,q,r = t[0], float(t[3]), float(t[4])
                    if r>(0.5*q):
                            if not d.has_key(p):
                                    d[p] = i
                                            d[p] += 1
                            pass
                    for k,v in d.items():
                            (w.write(('<tr><td>%s</td><td>%i</td>') % (k,v)))
                    w.write('</table></body></html>')
                    w.close()
    Attached Files
    Last edited by bvdet; Apr 13 '10, 02:13 PM. Reason: Add code tags

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      Nonemsludo,

      Thank you for posting. Please use code tags when posting code. Are you asking a question or sharing a solution? I moved your thread from the Python Insights forum because you provided no explanation of the purpose of the thread.

      BV - Moderator

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve

        Comment

        Working...