binaryfiles

How to Use Pyshark to Read a .pcapng file's content directly from memory instead of from disk?

How to Use Pyshark to Read a .pcapng file's content directly from memory instead of from disk? Question: I am using the file capture API of pyshark like this. #!/usr/bin/env python3 # encoding:utf-8 import pyshark as ps filename: str = ‘some_file.pcapng’ with ps.FileCapture(input_file=filename) as capture: print(capture[0].pretty_print()) But now, I have another use case where the …

Total answers: 1

Reading Images As JPEG VS Raw Data

Reading Images As JPEG VS Raw Data Question: I am developing a Python program where speed is critical, and one of its core components is reading JPEG natural images, with resolutions between 128 X 128 and 512 X 512, from disk. Currently, I utilize jpeg4py, a libjpeg-turbo-based library that is, in my experience, faster than …

Total answers: 1

Python3, binary data diffrent representation from what i need

Python3, binary data diffrent representation from what i need Question: I have to add an image to a database, so I open the image as binary and it stores it this way: b’x89PNGrnx1anx00x00x00rIHDRx00x00x00x01x00x00x00x01x01x03x00x00x00%xdbVxcax00x00x00x03PLTEx00x00x00xa7z=xdax00x00x00x01tRNSx00@xe6xd8fx00x00x00nIDATx08xd7c`x00x00x00x02x00x01xe2!xbc3x00x00x00x00IENDxaeB`x82′ However I need it to be strored this way: 0x89504e470d0a1a0a0000000d494844520000000100000001010300000025db56ca00000003504c5445000000a77a3dda0000000174524e530040e6d8660000000a4944415408d76360000000020001e221bc330000000049454e44ae426082 It is my first ever time working with binary files so there …

Total answers: 1

deleting a specific record from a binary file in python

deleting a specific record from a binary file in python Question: each record in binary files is stored like this import pickle student={} def add(): n=int(input("enter number of entries")) for i in range(n): name=input("enter names") marks=eval(input("enter marks")) student[name]=marks f=open("sample.dat","wb") pickle.dump(student,f) f.close() if want to delete a specific record with name=<"some name"> how to do it …

Total answers: 3

python get unicode string size

python get unicode string size Question: I have a binary file. This file contains an UTF-8 string. Moreover, it is guaranteed that this string is just a single word. In python, how can I get number of letters in this string? Let’s say, I opened this file and read bytes: bytes = open(“1.dat”, “rb”).read() What …

Total answers: 1

Reading 32 bit signed ieee 754 floating points from a binary file with python?

Reading 32 bit signed ieee 754 floating points from a binary file with python? Question: I have a binary file which is simple a list of signed 32 bit ieee754 floating point numbers. They are not separated by anything, and simply appear one after another until EOF. How would I read from this file and …

Total answers: 4