Re: How to write list of integers to file with struct.pack_into?

2023-10-03 Thread Roel Schroeven via Python-list
Jen Kris via Python-list schreef op 2/10/2023 om 17:06: My previous message just went up -- sorry for the mangled formatting.  Here it is properly formatted: I want to write a list of 64-bit integers to a binary file.  Every example I have seen in my research converts it to .txt, but I want

How to write list of integers to file with struct.pack_into?

2023-10-03 Thread Jen Kris via Python-list
My previous message just went up -- sorry for the mangled formatting.  Here it is properly formatted: I want to write a list of 64-bit integers to a binary file.  Every example I have seen in my research converts it to .txt, but I want it in binary.  I wrote this code, based on some earlier wor

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Jen Kris via Python-list
Dieter, thanks for your comment that: * In your code, `offset` is `0`, `1`, `2`, ... but it should be `0 *8`, `1 * 8`, `2 * 8`, ... But you concluded with essentially the same solution proposed by MRAB, so that would obviate the need to write item by item because it writes the whole buffer at o

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Dieter Maurer via Python-list
Jen Kris wrote at 2023-10-2 00:04 +0200: >Iwant to write a list of 64-bit integers to a binary file. Everyexample I >have seen in my research convertsit to .txt, but I want it in binary. I wrote >this code,based on some earlier work I have done: > >buf= bytes((len(qs_array)) * 8) > >for offset

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Jen Kris via Python-list
Thanks very much, MRAB.  I just tried that and it works.  What frustrated me is that every research example I found writes integers as strings.  That works -- sort of -- but it requires re-casting each string to integer when reading the file.  If I'm doing binary work I don't want the extra over

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread MRAB via Python-list
On 2023-10-01 23:04, Jen Kris via Python-list wrote: > > Iwant to write a list of 64-bit integers to a binary file. Everyexample I have seen in my research convertsit to .txt, but I want it in binary. I wrote this code,based on some earlier work I have done: > > buf= bytes((len(qs_array)) * 8)

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Barry via Python-list
On 2 Oct 2023, at 16:02, Jen Kris via Python-list wrote: Iwant to write a list of 64-bit integers to a binary file.  Everyexample I have seen in my research convertsit to .txt, but I want it in binary.  I wrote this code,based on some earlier work I have done: buf= b

How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Jen Kris via Python-list
Iwant to write a list of 64-bit integers to a binary file. Everyexample I have seen in my research convertsit to .txt, but I want it in binary. I wrote this code,based on some earlier work I have done: buf= bytes((len(qs_array)) * 8) foroffset in range(len(qs_array)): item_to_write= byt