On 2020-11-30 03:59, Jason Friedman wrote:
csv.DictReader appears to be happy with a list of strings representing
the lines.
Try this:
contents = source_file.content()
for row in csv.DictReader(contents.decode('utf-8').splitlines()):
print(row)
Works great, thank you! Question ... wil
>
> csv.DictReader appears to be happy with a list of strings representing
> the lines.
>
> Try this:
>
> contents = source_file.content()
>
> for row in csv.DictReader(contents.decode('utf-8').splitlines()):
> print(row)
>
Works great, thank you! Question ... will this form potentially use l
On 2020-11-30 01:31, Jason Friedman wrote:
Using the Box API:
print(source_file.content())
returns
b'First Name,Last Name,Email Address,Company,Position,Connected
On\nPeter,van
(and more data, not pasted here)
Trying to read it via:
with io.TextIOWrapper(source_file.content(), encoding=
En Thu, 19 Feb 2009 16:51:39 -0200, harijay escribió:
Hi I am very confused with the use of the struct module to read binary
data from a file.
( I have only worked with ascii files so far)
I have a file spec for a Data-logger (http://www.dataq.com/support/
techinfo/ff.htm)
That format is rat
harijay wrote:
Hi I am very confused with the use of the struct module to read binary
data from a file.
( I have only worked with ascii files so far)
I have a file spec for a Data-logger (http://www.dataq.com/support/
techinfo/ff.htm)
I am collecting some voltage , time traces on one channel an
Aaron Scott wrote:
Taking everything into consideration, my code is now:
import struct
file = open("test.gde", "rb")
signature = file.read(3)
version, attr_count = struct.unpack('II', file.read(8))
print signature, version, attr_count
for idx in xrange(attr_count):
attr_id, attr_val_le
On Sep 11, 4:16 am, Aaron Scott <[EMAIL PROTECTED]> wrote:
> Taking everything into consideration, my code is now:
>
> import struct
> file = open("test.gde", "rb")
> signature = file.read(3)
> version, attr_count = struct.unpack('II', file.read(8))
> print signature, version, attr_count
> for idx
What I would do first is to print the result byte by byte each as
hexadecimal number.
If you can I would additionally populate the C-structure with numbers,
which are easier to follow.
Example:
signature = "ABC" // same as 0x41 0x42 0x43
version = 0x61626364
attr_count = 0x65667678
. . .
a
On Sep 10, 1:12 pm, Aaron Scott <[EMAIL PROTECTED]> wrote:
> Sorry, I had posted the wrong error. The error I am getting is:
>
> struct.error: unpack requires a string argument of length 12
>
> which doesn't make sense to me, since I'm specifically asking for 11.
> Just for kicks, if I change
On Sep 10, 7:16 pm, Aaron Scott <[EMAIL PROTECTED]> wrote:
> Taking everything into consideration, my code is now:
>
> import struct
> file = open("test.gde", "rb")
> signature = file.read(3)
> version, attr_count = struct.unpack('II', file.read(8))
> print signature, version, attr_count
> for idx
Aaron Scott schreef:
Sorry, I had posted the wrong error. The error I am getting is:
struct.error: unpack requires a string argument of length 12
which doesn't make sense to me, since I'm specifically asking for 11.
That's because of padding. According to the docs, "By default, C numbers
Taking everything into consideration, my code is now:
import struct
file = open("test.gde", "rb")
signature = file.read(3)
version, attr_count = struct.unpack('II', file.read(8))
print signature, version, attr_count
for idx in xrange(attr_count):
attr_id, attr_val_len = struct.unpack('II',
Sorry, I had posted the wrong error. The error I am getting is:
struct.error: unpack requires a string argument of length 12
which doesn't make sense to me, since I'm specifically asking for 11.
Just for kicks, if I change the line to
print struct.unpack('3sII', file.read(12))
I get t
On Sep 10, 6:45 pm, Aaron Scott <[EMAIL PROTECTED]> wrote:
> > CORRECTION: '3cII' should be '3sII'.
>
> Even with the correction, I'm still getting the error.
Me being silly...
Quick fix:
signature = file.read(3)
then the rest can stay the same, struct.calcsize('3sII') expects a 12
byte string, w
On Wed, 10 Sep 2008 10:43:31 -0700 (PDT), Aaron Scott wrote:
>> signature, version, attr_count = struct.unpack('3cII',
>> yourfile.read(11))
>>
>
> This line is giving me an error:
>
> Traceback (most recent call last):
> File "test.py", line 19, in
> signature, version, attr_count = struct.
> CORRECTION: '3cII' should be '3sII'.
Even with the correction, I'm still getting the error.
--
http://mail.python.org/mailman/listinfo/python-list
> signature, version, attr_count = struct.unpack('3cII',
> yourfile.read(11))
>
This line is giving me an error:
Traceback (most recent call last):
File "test.py", line 19, in
signature, version, attr_count = struct.unpack('3cII',
file.read(12))
ValueError: too many values to unpack
--
htt
On 10 Sep, 18:33, Jon Clements <[EMAIL PROTECTED]> wrote:
> On 10 Sep, 18:14, Aaron Scott <[EMAIL PROTECTED]> wrote:
>
>
>
> > I've been trying to tackle this all morning, and so far I've been
> > completely unsuccessful. I have a binary file that I have the
> > structure to, and I'd like to read i
On 10 Sep, 18:14, Aaron Scott <[EMAIL PROTECTED]> wrote:
> I've been trying to tackle this all morning, and so far I've been
> completely unsuccessful. I have a binary file that I have the
> structure to, and I'd like to read it into Python. It's not a
> particularly complicated file. For instance:
Thanks,
I later discovered that it was a big edian binary as well.
Sheldon
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-03-22, Sheldon <[EMAIL PROTECTED]> wrote:
> I have a script that I want to use to read some binary lon and lat data
> that was written with a C program.
http://www.python.org/doc/current/lib/module-struct.html
--
Grant Edwards grante Yow! UH-OH!! We're out
"David M" <[EMAIL PROTECTED]> writes:
> Thanks but the C Struct describing the data doesn't match up with the
> list on the module-struct page.
>
> this is the acct.h file
[...]
Tooting my ctypes horn (sorry for that):
[EMAIL PROTECTED]:~/ctypes> locate acct.h
/usr/include/linux/acct.h
/usr/incl
"David M" wrote:
> What are u_ini16_t and comp_t?
comp_t is explained in the file you posted:
> /*
> comp_t is a 16-bit "floating" point number with a 3-bit base 8
> exponent and a 13-bit fraction. See linux/kernel/acct.c for the
> specific encoding system used.
> */
>
> typedef u_int16_t com
In comp.lang.python, "David M" wrote:
> Thanks but the C Struct describing the data doesn't match up with the
> list on the module-struct page.
Then you're going to have to do some bit-bashing.
> comp_t is a 16-bit "floating" point number with a 3-bit base 8
> exponent and a 13-bit fraction.
Thanks but the C Struct describing the data doesn't match up with the
list on the module-struct page.
this is the acct.h file
#ifndef _SYS_ACCT_H
#define _SYS_ACCT_H 1
#include
#define __need_time_t
#include
#include
__BEGIN_DECLS
#define ACCT_COMM 16
/*
comp_t is a 16-bit "floating
David M wrote:
> OK so here is my task. I want to get at the data stored in
> /var/account/pacct, which stores process accounting data, so that I can
> make it into a more human understandable format then what the program
> sa can do. The thing is, its in a binary format and an example program
>
On 2005-11-23, David M <[EMAIL PROTECTED]> wrote:
> OK so here is my task. I want to get at the data stored in
> /var/account/pacct, which stores process accounting data, so that I can
> make it into a more human understandable format then what the program
> sa can do. The thing is, its in a bina
27 matches
Mail list logo