Sorry for the slow response, was called away.

As a starting place I'll try to stick with the builtin routines first.  
With Stefan's idea I've got something that works though I don't see a way 
to make it more..  ummm...   elegant.

Here's where I'm at:
myfile = "dnp.sam"
dnp = { "File" => myfile }

fh = open(myfile, "r")

dnp["Label"] = bytestring(readbytes(fh, 4))
dnp["Version"] = reinterpret( Uint16, readbytes(fh, 2) )
dnp["Revision"] = reinterpret( Uint16, readbytes(fh, 2) )
dnp["Date"] = bytestring(readbytes(fh, 28))
# and so on for 30 other variables

close(fh)


Any suggestions?

@Tom :  I love how clean your code looks.
@gggg :  We may be after the same thing.




On Thursday, September 17, 2015 at 9:09:15 PM UTC-4, David McInnis wrote:
>
> I'm in the process of switching from python to julia and have gotten stuck 
> for a couple of days trying to read a, for me, typical data file.
>
> In python I'd create a C-style format, open the file and read the data.
> I don't see an equivalent method in Julia.
>
> Ex:
> Using a data structure of something like:    "<4sii28s4i"  
> I'd figure out the size of the structure, point to the beginning byte, and 
> then unpack it. 
>
> In Julia it looks like *maybe* I could make a data type to do this, but I 
> can't figure out how.
> There's also StrPack.jl,  but it too is a little beyond what I understand.
>
> I work with a lot of different instruments, each with its own file format. 
>  Usually I only need to read these files.  After processing I'll save 
> everything into an hdf5 file.  
>
> Thanks,  David.
>
>

Reply via email to