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

Similar Messages

  • Problem saving 2D array to binary file

    I am getting some strange results when trying to write a transposed 2D array of Unisgned 8-bit data to a binary file. Attached is an example program ("071026_ArraySave_Bug.vi") which demonstrates the suspicious behavior.
    The program generates a small 2D array of U8 data, then saves it to two temporary files using two different methods.
    1) Row-by-row: The 2D array is auto-indexed, and the indexed row is written to file at once (with the prepended size option disabled).
    2) Point-by-point: Two For loops are used to auto-index each element and write it to file individually.
    The saved files are then reopened and the data is read into two 1D arrays for display.
    The bug occurs when the generated 2D array is transposed before being saved to file. In the point-by-point method, the data is always saved to the file as desired, i.e. by row or by column depending on whether the data was transposed. However, in the row-by-row method the data is incorrectly saved when the input data is transposed. Without transposing the array, the row-by-row results are correct.
    Saving the array row-by-row is significantly faster for larger arrays, so this method is desired.
    Note that the option to transpose the input data in the attached VI is performed using a case structure with a boolean constant ("Bug Control"). This is important because:
    1) The bug does not occur if the boolean constant is replaced with a control.
    2) The bug does not occur if the case structure is replaced with a "Select" node from the Comparison Palette.
    3) The bug still occurs if the case structure is removed such that the array is always transposed (i.e. keep the True case).
    For now, I have been able to circumvent the bug in practice by transposing the array and then passing it through a Select with a constant True (the False case uses the untransposed array). This allows the faster row-by-row method to be used without error, but requires new memory allocation for the transposed array.
    I will appreciate any help that can be given regarding this problem, or simply confirmation that it is indeed a bug in Labview 8.5. It is worth noting that the same program did not produce any errors when run in Labview 7.
    Thank you for your help,
    David Viggiano
    Attachments:
    071026_ArraySave_Bug.vi ‏29 KB

    This is a known bug (CAR : 4DP855N3) , related to memory management. see this thread
    If I remember well, Altenbach shown somewhere that forcing the transpose operation to produce a copy of the memory was a proper workaround.
    Message Edité par chilly charly le 10-26-2007 08:40 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    071026_ArraySave_Bug[1].png ‏2 KB

  • 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

  • How do I write a cluster of an array to a file that can be looked at with other applications?

    I have a cluster of array that are different data types. How do I write this to a file, so that other applications can read it, i.e. notepad etc?

    Each elements of the array has a cluster of different data. It is unbundled and separated by a comma , then converted to a string. It is indexed out to a CSV array and then written to a spreadsheet file. The spreadsheet file reads it and outputs a CSV array. This is then going into for loop to reassemble the string output to its original clustered data representation. The iterations puts the clusters back into the array at the correct indexed position.hint: the for loop is the key to manipulating the array data...this VI is like an egg to a chicken and chicken to an egg, whatever came first?
    Attachments:
    disassemble_assemble ARRAY.vi ‏20 KB

  • How to write a Data Plugin to access a binary file

    hi
    Im a newbee to DIAdem, i want to develop a data plugin to access a binary file with any number of channels.For example if there around 70 channels, the raw data would in x number of files which will contain may be around 20 channels in each file . Raw file consist of header(one per file), channel sub header(one per channel),Calibration Data Segment(unprocessed datas) and Test data segments(processed data)....
    Each of these contains many different fields under them and their size varies ....
    Could suggest me some procedure to carry out this task taking into consideration of any number of channels and any number of fields under them....
    Expecting your response....
    Jhon

    Jhon,
    I am working on a collection of useful examples and hints for DataPlugin development. This document and the DataPlugin examples are still in a early draft phase. Still I thought it could be helpful for you to look at it.
    I have added an example file format which is similar to what you described. It's referred to as Example_1. Let me know whether this is helpful ...
    Andreas
    Attachments:
    Example_1.zip ‏153 KB

  • How to store 2C array to a singl binary file

    Hi
    I have to store multiple waveforms output that is each 1D array to a single binary file. how do i do this.
    i can store 1D array to binary file and retrieve it by reading the binary file and plotting the waveform. but i am not able to store 2D array to the single file. how do store many 1D array in one binary file,
    Thank you. Hema

    (We would also need to know your LabVIEW version. If you have a very old version, things would be quite different.)
    As Smercurio_fc already mentioned, the option to "prepend array size" would make things much easier here, because then you would read it as a single 2D array.
    Here's how that would look like. This is probably the recommended solution, just for simplicity reasons.
    Not prepending the size is more useful if you write the data in increments, but later want to read it as one.
    Message Edited by altenbach on 11-15-2008 09:02 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SaveRestore2D.png ‏21 KB

  • What is the best combination of read and write objects to binary files ...

    Hi everyone,
    what are the best combination of read and write objects to read/write a record of customers from a binary file. I should be able to use StringTokenizer. I am bit confused with all these Stream reader and writers.
    abdul

    You are, indeed, confused:
    o StreamTokenizer works on character input, not binary input.
    o Readers and Writers in general work on character streams, not binary.
    That leaves you various input streams and output streams for reading binary data.

  • Read/Write 2d numeric array or string array into bin file

    Can anyone pls help me to resolve this problem
    Attachments:
    bin file.vi ‏9 KB

    You are still using the wrong format.
    Whatever you are doing has nothing to do with a binary file.
    You are still using way too much duplicate code.
    All you probably need is read/write from spreadsheet file, no need to reinvent the wheel.
    Your code will fail if the numbers contain decimal digits (since your array is DBL, it could! If your array only contains integers, you are using the wrong numeric representation).
    You string code will fail if the array elements contains tabs, for example.
    You still don't need a sequence structure.
    LabVIEW Champion . Do more with less code and in less time .

  • Write string array into cfg file

    Hi, everybody.
    I faced the problem to write array into cfg file. I am trying to put many items in a key. It should look like
    [Section1]
    Key1=el_1, el_2,el_3,.............el_n.
    each element is string of 105 characters. Everything works fine when I save the only one el_1 or multiple for the  first time, however, when I am trying to update values in a key section some extra strings appear in a file. My VI is attached.
    Thanks in advance

    Do you realize that your spreadsheet string only writes the following:
    1111111111
      2222222222222222
     33333333333333333333
    The way you wrote your VI, it sends the entire string above to the value for Write Key.vi.
    Do you realize that value is for the data type only?  So I'm not sure what you want to do....
    Without describing the problem you are having, can you describe what you actually want to do?
    R
    Message Edited by JoeLabView on 07-22-2008 11:49 AM
    Attachments:
    confused.PNG ‏26 KB

  • Write Text Data Array to text file

    Greetings all. I hope someone can help me as I am really under the gun. The attached vi shows the basics of what I am trying to do. I have already written a vi that takes the Cal Data Array and prints it out in a nicely formatted report. My problem is that the powers that be also want the data saved to a generic text file that can be copied and printed out anywhere they like. As such, I need to save the data to a generic text file in column format such that it will all fit on one page in landscape mode. There are a total of 12 columns of data. I have been trying to create something that would format each column to a specific length instead of them all being the same. No luck so far. Basically, I need columns 1,2,3,8 and 12 to be length of 5. The rest a length of 9. I have tried to place the formatting part in a for loop with the formatting in a case, but it does not appear to work. I really need this quick so if anyone has any ideas, please help. As always, I really appreciate the assistance.
    Thanks,
    Frank
    Attachments:
    Write Cal Data to Text File.vi ‏21 KB

    pincpanter's is a good solution. Beat me to it while I was away building an example. Similiar approach using two for loops and case statement. Here is my suggestion anyway....
    cheers
    David
    Message Edited by David Crawford on 11-23-2005 09:37 AM
    Attachments:
    Write Text Data Array to text file.vi ‏31 KB

  • Multiple writes possible in DS in labview but not in CVI?

    Hi
    Am using Datasocket to communicate between to VI's, In one of the VI's am opening a new dataitem in "readwrite" mode and doing both read and write operation, and in the other VI am just writing on the dataitem by supplying the URL to the write function, surprisingly this is possible even though i havent created the dataitem from DS manager and have not selected the option of "allow multiple writes".
    But if am creating a CVI application, which opens the dataitem in "readwrite" mode, and if i write on that dataitem from labview, it gives me an error, i even tried selecting the "allow multiple write" on this dataitem.
    Please suggest some solution. Also if i open a lot of Dataitems will it cause any problems?, i guess our project needs atleast 100 dataitems if i will have to use command and response in different dataitems.
    thanx for the help
    Arun

    Hello,
    The following Knowledge Base describes two possible soltions for this issue.
    Why Does My DataSocket Connection in LabVIEW Fail with "Error: Can't connect to data item, another w...
    The second solution is what you have already described with checking the box to Allow Multiple Writers. I am not sure why that is not working in your case, but I would suggest trying the first soltuion suggested in the KB. It involves creating the datasocket item a certain way in LabVIEW, and more details are available in the KB.
    Scott Y
    NI

  • Write array into txt file

    Hi Guys!
    I need a VI which writes the content of an array into a txt file.
    I have an array like this:
    Peti    Teri
    Zoli    Hajni
    Tomi    Heni
    Pali    Robi
    In the file the first line should be a full timestamp (date, time), and then would come the content of the array. The name of the file would also be a timestamp.
    Thank you for your help in advance!

    Hi Victronica and welcome to NI Forums!
    If you have some custom data, then it is up to ou to tell excel how to interpret said data (what information to put where, etc.) A simple solution would be to flatten your cluster elements into strings, and write those strings into an excel sheet using ActiveX. An example on how to write a table of strings is available in the example finder, and I also have it attached here in LabVIEW 2013.
    Kind regards:
    Andrew Valko
    National Instruments Hungary
    Attachments:
    Excel - Write Table.vi ‏17 KB

  • How to write a 2-D Array of Doubles to a binary file in LabView 8.5?

    Okay, this is driving me nuts. I got a program that worked fine in LabView 8.0 but refused to write any data after my institute upgraded to LabView 8.5. The data is stored in a 2-D array of doubles and is supposed to be written to a binary file, that has been correctly opened and got a header written to it containing some meta-data of the measurement. But when the doubles from the array should be written to the file, nothing happens. All I get is an (except for the header) empty file of 786 kB. I found out that writing works if I convert the data from the array to singles right before wiring them to the "write to binary file" VI, but for several reasons I need the data as doubles. Can anyone help me? I've tried everything anyone has written here about writing to binary files and more.
    Remember, it worked perfectly fine with an older version of LabView. Any ideas?

    It is possible that you run into a known memory optimization bug.
    Try to place an "always copy" primitive as discussed here.
    Message Edited by altenbach on 11-18-2008 09:11 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Write an object that has array

    I am trying to figure out how to write a object with an array
    Player[] jim = new Player[30];
    for (int i=0;i<30;i++)
    jim= new Player("" + i);
    I am trying to figure out how to get the number of points jim scores in a month, so i need 31 days and a way to input the number of points he scored. Any help would be great

    Well, i think you don't have to create a whole bunch of arrays to enter jim's scores in 31 days. I presume you already have a separate object called Player. Why not set a List attribute on that object and manipulate the scores there. You don't need to instantiate an array for that.
    public class Player{
        private List scores = null;
        ....... //other attributes here
        public Player(){
            scores = new ArrayList();
        public void addScore(String score){
            scores.add(score);
        public List getScore(){
            return scores;
    }well, of course to get the contained items from the List, do manipulate it using arrays. And well, just parse down the returned scores to int because they are stored as strings here.
    hope that helps.

  • Write two arrays to a file

    I am wanting to write 2 2D arrays to a file and have them side by side, not one on top of the other. Is there a way to do this? I am basically taking a data set from one test which has several line and columns and then taking similar data and wanting them next to each other so I can sync up the times then do some manipulation of the data as a whole. Any help is appreciated.

    One caution is that if your two arrays don't have the same number of rows, the result will be truncated to the shorter of the two. If that's a possibility you'll have to do some padding (with zeros or empty strings).
    =====================================================
    Fading out. " ... J. Arthur Rank on gong."
    Attachments:
    Side_by_Side_Unequal_Arrays.vi ‏40 KB

Maybe you are looking for