I am trying to convert pcap files to csv for all files in a folder using python .My code does not give me any error neither the output.Actually I can do it with the tshark command line but I wanted to try it in python.Btw I am new to python
I am trying to convert pcap files to csv for all files in a folder using python .My code does not give me any error neither the output.Actually I can do it with the tshark command line but I wanted to try it in python.Btw I am new to python
Here's my code:
import os
import glob
file_path='path/to/pcap/files'
def create_csv(filename):
x=f'tshark -r {filename} -Y sip -T fields -e ip.src -e ip.dst -e sip.From -e sip.to -E header=y -E separator=, > {filename}.csv '
print(x)
os.system(x)
for filename in glob.glob(file_path + '*.pcap'):
create_csv(filename)
First of all, make sure that the common issue under are valid for you.
Common mistake :
Make sure that your pcap file is, indeed a pcap file. Wireshark save by default in a .pcapng format.
ls -alF path/to/pcap/filesMake sure that your program are fetching those files. You can use a print like so :
tsharkis installed (apt install tshark on linux)Solution :
Check if the solution is working :