MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Reading Binary Data from SQL Request

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110403] Re: Reading Binary Data from SQL Request
  • From: "Hans Michel" <hmichel at cox.net>
  • Date: Wed, 16 Jun 2010 05:41:44 -0400 (EDT)
  • References: <hv76ig$k0q$1@smc.vnet.net>

Try

myRealDataString = FromCharacterCode[ data[[1, 1, 1]] ];

myRealDataStream = StringToStream[myRealDataString];

num = BinaryRead[myRealDataStream , "Real64"];

Not sure of above step as I don't have a db with bunary data that can be 
read as 64-bit IEEE double-precision numbers.

Close[myRealDataStream]

Hans

"Stephan Schiffels" <stephan80 at mac.com> wrote in message 
news:hv76ig$k0q$1 at smc.vnet.net...
> Dear group,
>
> I use DatabaseLink to retrieve binary data from a database.
> So lets say, I retrieve the data as:
>
> Needs["DatabaseLink`"];
> conn = OpenSQLConnection["myDB"];
> data = SQLSelect[conn, "myTable", "myBinaryField"];
>
> Then the type of data[[1,1]] is an SQLBinary-Object, containing a list of 
> bytes, accessible as the first item of the SQLBinary-Wrapper: 
> data[[1,1.1]]
>
> I need to read this binary data as a sequence of double precision floating 
> point numbers, similar to the following command:
>
> BinaryRead[stream, "Real64"], where "stream" is a file on the harddisk.
>
> I have not figured out how to do this with binary data that is already in 
> memory, rather then in a file. All I can find in the documentation is 
> concerned with File I/O.
>
> What I can do is to use a temporary file:
>
> BinaryWrite["tmp", data[[1,1,1]]];
> Close["tmp"];
> num = BinaryRead["tmp", "Real64"];
>
> But there clearly should be a way to avoid the creation of binary files 
> here...
>
> I appreciate any help.
>
> Thanks,
>
> Stephan
>
> 



  • Prev by Date: Re: how to scale text to a bounding rectangle?
  • Next by Date: Re: Reading Binary Data from SQL Request
  • Previous by thread: Reading Binary Data from SQL Request
  • Next by thread: Re: Reading Binary Data from SQL Request