Binary file problem (Read a specific Stream)

Hi Guys ,
I have a problem , I want to read a binary files but not the whole binary file. I only want to read one stream.
Forexample , I have a binar files which has 5 streams. If I only want to read one of the stream what should i do ? How do i get the position of each stream starting and end ?
The binary file is attached.
Please note that the file was 5.7mb where as labview message system allows 5.2mb. therfore i uploaded the file on a file host
http://uploading.com/files/55524a3d/10211001_.raw/
Thankyou in advance
Rgs
M Omar Tariq

As far as I can understand. You are able to read and decode the file in Labview. But have problems with big files. In such cases. Read the data file in chunked and discard data not needed. You can also make a tool that splits the multi-channel data into separate files in a binary format easy to read from Labview. It is also not needed to have all the data in memory then analyzing the data. Analysis may in many cases be done in chunks.
Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)

Similar Messages

  • Can a binary file be read incrementally?

    I have a situation where I would like to do repeated incremental reads (i.e., N bytes at a time) from a binary file. My understanding of the Read Binary File VI is that you open the file, read N bytes from the file, and close the file - i.e., do a SINGLE read. I don't want to read the WHOLE file into memory at one gulp; I want to keep repeating the N-byte read operation in an indefinite loop, until I say to stop. On each read I will be updating a graph with the last data read.
    (OK, some more detail: I am monitoring 32 digital lines using some external equipment that writes the file. Each time one of the digital lines changes value, 10 bytes are written: a 48-bit timestamp and 32 bits for the current digital values. The file is a continuous little-endian raw concatenation of these 10-byte records, with no header or record markers. In LV 8.21 (under WinXP) I want to generate a scrollable display of the 32 digital traces, by reading a block of data as needed whenever I want to advance the display.)
    What is the suggested way to handle this kind of binary reading? (I am willing to write C code if necessary.) Any useful responses will be appreciated.
    dhfx

    This may be lower level than you were looking for.  As already mentioned, the big problem may be having two applications accessing the file simultaneously.
    Jim
    Jim
    LV 2013
    Attachments:
    ReadBinary.png ‏4 KB

  • Binary file problem

    I am writing to a binary file. My poblem is that i want that the next time it write to the file it will write on a new line. What can i do? Thanks a lot.
    This is the piece of code that writes to the file:
                         File aFile  = new File( "players.dat" );
                         // create an output stream to the file
                         FileOutputStream aFileOutStream = new FileOutputStream ( aFile, true );
                         // create a data output stream to the file output stream
                         DataOutputStream aDataOutStream = new DataOutputStream ( aFileOutStream );
                         // write data to file
                         aDataOutStream.writeUTF(player);
                         aDataOutStream.writeUTF(String.valueOf(percent) );
                         aDataOutStream.writeUTF(type );
                         aFileOutStream.close();

    kopl wrote:
    I am writing to a binary file. My poblem is that i want that the next time it write to the file it will write on a new line. What can i do? Thanks a lot.I'm confused. I'm no expert in I/O, but When I hear "new line" I think "text file"; "new line" and binary files just don't seem to mix properly in my mind.

  • Write string (7 chars), int16, sgl into binary file and read it in C

    How to write write string (7 chars), int16, sgl, string (5 chars) into binary file and then read it in C ?
    Total 18 Bytes file (binary) should be created.

    Hi,
    this could be done that way:
    You have to make sure the strings have their correct length!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Labview binary file format, reading in matlab

    Hi,
    I have some binary files that I wrote in Labview containing data of type double.  I'm trying to load the data in Matlab but I am not having much success.  In Matlab I am using the fread command and specifying the type as double with the machine format as 'b' for big-endian.  But the values I get do not make any sense.  Does anyone know what format Labview saves the data in?  Is it big-endian?  Or something else?
    Thanks,
    Todd

    LabVIEW stores data in BIG endian format. This was done to maintain compatability between all of the different platforms that LabVIEW runs on. And of course is an inheritance of the original Macintosh LV versions. There is a shipping documents that presents all the data storage formats. Just do a search in the LabVIEW bookshelf.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Problem in Writing to/Reading from a Binary file placed in a Loop

    Hi
    As you can see in the attahced image, I attempt to write a set of 2*202 data in each iteration of the loop of the loop, yet when I try to read the data (in the second picture) I only get the first (or last, I assume) set of data, up to index 202. I needed to read two set (X, Y) of 402 valuse. So, I am not sure if I am making a  mistake in wrting to the file or reading from it! 
    I really appreciate it if someone could suggest a solution
    Ashakn
     

    You are only reading the first.  In your read, set your number to read to -1.  That will tell the Read Binary File to read all of the data instead just a single set.

  • Multiple writes of a DBL 2D array to binary file

    Hello.
    Does anyone have an example of writing a 2D array to a binary file multiple times?
    Specifically, I need to write a 2D array of DBL to a binary file mulitple times and then (later) be able to read it back (reconvert to DBL). All of the examples that I've found only do one write and then close the file. I need to leave the file reference open and write data to it over the period of a few days. The data comes out of a queue that is fed from a DAQ loop. (In an acquistion loop I feed a queue and in a slower loop I dequeue the data and write it to disk)
    I believe it has something to do with the pos mode and offset mode but I can't figure it.
    I haven't been able to successfully read the data back yet from the .bin file so I'm not sure if I'm even writing it correctly.
    The closest example that I've found is the High Speed Data Logger and High Speed Data Reader but I haven't had any luck with those.
    Thanks in advance.
    Steve
    LabVIEW 7.1
    Solved!
    Go to Solution.

    To change the representation of a number, use the Numeric > Conversion sub-palette.
    The example below shows that the wires contain the representation info independently of the destination indicators : you can connect different types of numerics to the same wire and LabVIEW will automatically adapt to the type (the coercion dots indicate that a convertion has been done). Everything you should want to know about converting numbers is explained in the LabVIEW Help : "Conversion VIs and Functions"
    Message Edited by chilly charly on 07-30-2005 10:57 AM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Convert to single.png ‏27 KB

  • Binary file save - bug in lv8 for MAC ?

    Hi,
    Using LV8 on Mac OSX, I found a bug concerning binary file saving (attached file).
    Write an array of double in a binary file. Read it back.
    If you used little endian,ok. If you used Big-endian, result is wrong (but no error).
    Could a mac user replicate ?
    Boris Matrot
    Attachments:
    bin_file_save_lv8_mac.vi ‏14 KB

    Just as an additional data point, everything works fine under Windows.
    (As a workaround, have you tried flattening the data for writing? I don't have a MAC, so I cannot test.)
    Message Edited by altenbach on 01-19-2006 12:41 PM
    LabVIEW Champion . Do more with less code and in less time .

  • How can I read a binary file stream with many data type, as with AcqKnowledge physio binary data file?

    I would like to read in and write physiological data files which were saved by BioPac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/ app156Fi
    leFormat/FileFormat.htm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/ app155macffmt/macff.htm).
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, I was a little unsure which LabView data types correspond to int, char , short, long, double, byte, RGB and Rect. And, since it is for PC I am also assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    Two samples *.acq binary files are attach to this post to the list. Demo.acq is for version 3.7-3.7.2, while SCR_EKGtest1b.acq was recorded and saved with AcqKnowledge 3.8.1, which version number is 41.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to i
    llustrate it.
    Many thanks in advance for your help.
    Donat-Pierre
    Attachments:
    Demo.acq ‏248 KB
    SCR_EKG_test1b.acq ‏97 KB

    The reading of double is also straight forward : just use a dble float wired to the type cast node, after inverting the string (indian conversion).
    See the attached example.
    The measure of skin thickness is based on OCT (optical coherent tomography = interferometry) : an optical fiber system send and received light emitted to/back from the skin at a few centimeter distance. A profile of skin structure is then computed from the optical signal.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Read_AK_time_info.vi.zip ‏9 KB

  • How can I read a binary file stream with many data type, as with AcqKnowled​ge physio binary data file?

    I would like to read in and write physiological data which was saved by Biopac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/app156FileFormat/FileFo​rmat.h
    tm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/app155macffmt/macff.ht​m) .
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, because it is for PC I am assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to illustrate it.
    Many thanks in advance for your help.
    Donat-Pierre

    One more step...
    short are U16 integer
    double are double precision float
    bool seem to be 2 bytes (= U16)
    char are string (variable length)
    rgb are U16 integer, with high order byte = 0
    rect should be 4 x U16 (top, left, bottom, right)
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Problem when streaming out a binary file

    Hi,
    I am trying to stream out a binary file to an output stream (not a file, but a socket). My file is a gzip file, and I was initially simply trying to open the
    file, read it to a a byte array, and writing it out to my output stream. However, I got corrupted data at my other end and it took me quite a bit of
    debugging hours to find out why.
    I tried writing to a file the same information I was writing to my output stream but, although my file was correct, my output stream still contained
    corrupted data.
    I think I have finally narrowed down my problem to the fact that when I try to write a 0x00 value to my output stream, everything gets ignored from this
    point until I write a 0x0a byte to my output stream. Obviously this produces corrupted data, since I need all the bytes of my binary file.
    If somebody can direct me as to how to write a 0x00 value to a socket output stream, I would really appreciate your input.
    This is a sample of my code (Right now I am writing byte by byte: not very efficient, but was the only way I found where I was getting a problem):
    // out is of type OutputStream
    if (Zipped){
         // In this case we just have to stream the file out
    File myFile = new File(fileName);
         FileInputStream inputFile = new FileInputStream(myFile);
         FileOutputStream fos = new FileOutputStream(new File("/tmp/zip.gz")); //zip.gz results in a good (not corrupted) file.
         ByteArrayOutputStream out1 = new ByteArrayOutputStream(1024);
         int bytes = (int)myFile.length();
         byte[] buffer = new byte[bytes];
         bytes = inputFile.read(buffer);
         while (bytes != -1) {
              out1.write(buffer,0,bytes);
              bytes = inputFile.read(buffer);
         inputFile.close();
         try {
              int count=0;
              bytes=out1.size();
              while (count<bytes){
                   fos.write(buffer,count,1);
    out.write(buffer,count,1); // when buffer[count] == 0x00, everything after it gets ignored until a 0x0a byte is written.
                   count++;
         } catch (IOException ioe) {
              SysLog.event("IOEXCEPTION: "+ioe);
         } catch (Exception e) {
              SysLog.event("EXCEPTION: "+e);
         fos.flush();
         fos.close();
         out.flush();
    out.close();
         return;
    }

    Actually, I had thought about that and for some time I tried getting rid of some of the header information in the gzipped file, and then I stopped doing that when I realized that part of the gzipped file is a CRC value which I believe is computed taking into account both the data of the file and the header information. If this is the case, then getting rid of part of the header would produce a corrupted file ... but then, I might be wrong in this issue.
    Anyway, to make my application more clear, what I am doing is writing the code for a cgi command which is suppossed to access information from a database, create an xml file, gzip it, and then send it to the client who requested the information.
    Therefore, what I am sending is an xml file (Content-Type: text/xml) in compressed format (Content-Encoding: gzip). Note that if I don't gzip the file and then send it uncompressed to the client, I have no problems. However, for me it is very important to gzip it because the size of the file can get very large and that would just take bandwidth unnecessarily.
    On the other hand, if I try to gunzip the file locally, I have no problem either (the file is not corrupt at the server's end). Therefore, my problem is when I stream it out.
    Any further help would be really appreciated!

  • Problem rendering certain bytes when reading binary file

    I have a two part problem. I am trying to read files of any type from a client and transfer them over a pipe to a UNIX host running a C API. I have this process working for text data just fine however when I try and submit binary data there appears to be some data loss. Most of the file appears to end up on the host but it just isn't as long as the source, nor will it render correctly.
    In investigating this problem I tried to simply output a temporary copy of the transferred file on the client as I was reading the file just to see if my "thinking/process" was correct. The copy of the file ends up the same length but some bytes seem to have been misread. Upon doing a windiff on the source and copy it appears that several characters that are rendered as blocks in the original show up as '?' in the destination file.
    I believe this is an entirely different problem than why I am losing data on the host side but I want to first figure out why this problem is occuring. The below code is how I am reading and writing the binary file. I realize it has some problems with it, it is more of a POC at this point.
               final int BUF_SIZE = 1000;  // 1K
               char[] cBuffer = new char[BUF_SIZE];
               byte[] bBuffer = new byte[BUF_SIZE];
               int read = BUF_SIZE;
               long length = fLocalFile.length();
               FileInputStream fis = new FileInputStream(fLocalFile);
               DataInputStream dis = new DataInputStream(fis);
               FileOutputStream fos = new FileOutputStream("C:\\temp.file", false);
               DataOutputStream dos = new DataOutputStream(fos);
               for (int start = 0; start < length && reply.getSuccess(); start += read)
                   System.out.println("length: " + length + " start: " + start);
                   read = dis.read(bBuffer, 0, BUF_SIZE);
                   // Send the file data
                   String sTemp = sDestName + ":" + new String(bBuffer,0,read);
                   dos.write(bBuffer,0,read);
                   reply = axBridge.execute (Commands.CMD_FILE_TRANSFER_SEND, sTemp);
                dos.close();
            }It seems as if when reading or writing on the data streams some of the characters aren't getting converted correctly. Can anyone help? I've been testing with a PDF if that sheds any light.

    Yes but you ARE converting to a String first which you then send to the axBridge (sTemp!). Try just sending the bytes. You can easily pre-pend the "<filename>:" by sending those first.
    I know that some conversions occur when converting to a String, what they are exactly and what the exact effects are escapes me. Past experience though has taught me to ALWAYS send bytes, with no conversions, what you read is what you send.
    You may need to modify the send/receive protocol so that you send the command first with the filename then the bytes are sent after...
    As for why the file is not being written correctly to: c:\\temp.file, don't know... try the following code, it tends to be one of the "standard" ways of "streaming" data...
         byte buf[] = new byte[bufSize];
         int bRead = -1;
         while ((bRead = in.read (buf)) != -1)
             out.write (buf,
                     0,
                     bRead);
         }     And try just using a FileOutputStream or wrapping in a BufferedOutputStream.

  • I have written a binary file with a specific header format in LABVIEW 8.6 and tried to Read the same Data File, Using LABVIEW 7.1.Here i Found some difficulty.Is there any way to Read the Data File(of LABVIEW 8.6), Using LABVIEW 7.1?

    I have written a binary file with a specific header format in LABVIEW 8.6 and tried  to Read the same Data File, Using LABVIEW 7.1.Here i Found some difficulty.Is there any way to Read the Data File(of LABVIEW 8.6), Using LABVIEW 7.1?

    I can think of two possible stumbling blocks:
    What are your 8.6 options for "byte order" and "prepend array or string size"?
    Overall, many file IO functions have changed with LabVIEW 8.0, so there might not be an exact 1:1 code conversion. You might need to make some modifications. For example, in 7.1, you should use "write file", the "binary file VIs" are special purpose (I16 or SGL). What is your data type?
    LabVIEW Champion . Do more with less code and in less time .

  • How to read binary files wrt specific BYTE size and length??

    Hello Everyone,
                                I have a project I want to accomplish. I have a binary file, and I would like to read the data and print on wfm in a specific order and size.
    The data is 16 bit binary type , and needs to be read in chunks of 2 bytes.
    i have 30 bytes of sample 1.
    followed by 2 bytes of sample 2.
    followed by another 2 bytes of sample 3.
    steps 2-4 should be repeated 10 times and then i should read sample 4 which is of 2 bytes.....
    How should I do it?? I don't have any VI build... all i have is the example VI...
    can anyone pleasehelp me???
    Now on LabVIEW 10.0 on Win7

    smercurio_fc, sorry for the confusion, i will try my best to explain...
    1. No, i don;t have to read the file again, once it has read, I used
    while loop just to see the data updating (i press run, and before i can
    visualize i have the waveforms; i can get rid of the while loop)
    2. I have 30 different values of 1 sample. actually, the data is cmg
    from tri-axial accelerometer; each axis is of 10 bytes(hence 3*10 =
    30bytes)
    3. I am repeating the steps 2-4 10 times because the data was written
    into the binary file after 10 times sampling the sensors(if first 3
    samples are read @ 1000hz, sample 4 was read at 1000/10 = 100hz)
    4. I am using the graphs to interpret the values, that's it. The
    values are already scaled when they were wrote to the binary file, I
    have to simply interpret it.
    I have made some changes in the VI, now i am reading only the first
    30bytes, that too, in chunks of 10-10-10 bytes, and plotting the 3
    samples simultaneously on a waveform chart. (will approach 1
    sensor/sample at a time) and running the loop for 10 times. I have changed I8 to I16 now.
    Please let me know if it makes sense to you now.
    P.S. each sample is a sensor data.
    Now on LabVIEW 10.0 on Win7
    Attachments:
    data_read.vi ‏24 KB

  • Error when reading back a binary file

    Hello,
    I am writing out a binary file consisting of U32 arrays, packed strings, and clusters. I get error 116 when reading back. As long as I am synchronized on the correct data position why should LV care what I write to the file? In the example I write a simple 16 element array and a time stamp cluster. When reading back the array I get the error. What is the correct way to do mixed structures? Thanks.
    Attachments:
    file write.PNG ‏44 KB

    David,
    You can solve the problem in various ways. The easiest might be to modify the writer VI by wiring a True constant into the "header (F)" input of your first Write File node. That forces LabVIEW to include a four-byte header that specifies the length of the array you are writing.
    When you wire up the reader code the way you did, the length of the array you wire to the "byte stream type " input is irrelevant; by wiring nothing into the "count" input, you are implicitly telling LabVIEW to look for a header to determine the length of the array you are asking it to read. Because you didn't write any header, LabVIEW is interpreting the first four bytes of the array itself as a length. That length doesn't match the actual amount of data present in the datafile, so LabVIEW generates your error.
    An alternative solution would be to leave the writer unchanged and modify the reader VI: wire an I32 constant into "byte stream type" and wire a 16 into "count". The choice depends on what you prefer and whether or not these binary files need to be compatible with some other program or not.
    Another aside: you can dispense with your case that checks whether the datafile already exists. Just change the function input of the Open/Create/Replace to "create or replace" and wire a False constant into its "advisory dialog" input.
    Hope that's clear,
    John

Maybe you are looking for