Maybe this is what you are looking:
https://github.com/DavidRamosArchilla/pyflowmeter?tab=readme-ov-file#get-csv-analysis-from-a-pcap-file
from pyflowmeter.sniffer import create_sniffer
sniffer = create_sniffer(
input_file='path_to_the_file.pcap',
to_csv=True,
output_file='./flows_test.csv',
)
sniffer.start()
try:
sniffer.join()
except KeyboardInterrupt:
print('Stopping the sniffer')
sniffer.stop()
finally:
sniffer.join()