Open and reading multiple pcap files
Question: I'm trying to find out how I can use the dpkt module to open **multiple**
.pcap files and read them at the **same** time. After much googling and many
long hours, the examples which I manage to find only shows how you can open
and read 1 .pcap file.

I've tried using more than 1 for loop, and to zip() the files using an array
but to no avail. There is an error, ValueError: need more than 1 value to
unpack. Any suggestions? Here is my current python script:

    
    
      import dpkt, socket, glob, pcap, os
    
        files = [open(f) for f in glob.glob('*.pcap')]
        abc = dpkt.pcap.Reader(file("abc.pcap", "rb"))
        fgh = dpkt.pcap.Reader(file("fgh.pcap", "rb"))
    
        print files
        print "\r\n"
        List = [abc, fgh]
    
        for ts, data in zip(List):
           eth = dpkt.ethernet.Ethernet(data)
           ip = eth.data
           tcp = ip.data
    
           src = socket.inet_ntoa(ip.src)
           dst = socket.inet_ntoa(ip.dst)
    
           if tcp.dport == 80 and len(tcp.data) > 0:
              http = dpkt.http.Request(tcp.data)
              print "-------------------"
              print "HTTP Request /", http.version
              print "-------------------"
              print "Type: ", http.method
              print "URI: ", http.uri
              print "User-Agent: ", http.headers ['user-agent']
              print "Source: ", src
              print "Destination: ", dst
              print "\r\n"
    

**EDIT://**

Hey, thanks for all the suggestions. In order to simplify the process, I've
modified my code to open .txt files for now. My code is found below as
indicated. There is no error as shown in the output, but how do I get rid of
the new lines symbol '\n', the brackets and the single quotes when I print the
output?

**Code:**

    
    
     import glob
    
        fileList = [glob.glob('*.txt')]
    
        for files in fileList:
           print "Files present:",files
           print ""
    
           a = open("1.txt", 'r')
           b = open("2.txt", 'r')
    
           List = [a,b]
    
           for line in zip(*List):
              print line
    

**Output:**

    
    
    >Files present: ['2.txt', '1.txt']
    >
    >('This is content from the FIRST .txt file\n', 'This is content from the SECOND .txt file\n')
    >('\n', '\n')
    >('Protocol: Testing\n', 'Protocol: PCAP\n')
    >('Version: 1.0\n', 'Version: 2.0\n')
    


Answer: `zip()` takes each thing to iterate over as separate arguments.

    
    
    for ts, data in zip(abc, fgh):
      //...
    

By making the list first, you are only giving `zip()` on thing to iterate
over, that thing just happens to contain things that can be iterated over.

