Write 2D data array to spreadsheet with good alignment

Using "write to spreadsheet file" function to write 2D array,   I always have the problem that headers cannot align well wiith the data. See attached snapshot please (There are 7 column headers.)
WT
LV2013sp1
Solved!
Go to Solution.

Plain text display cannot handle tabs very well.
You can take the spreadsheet file and open it in e.g. excel and it will all look great. Spreadsheet files have no formatting information, just row and column delimiters.
If you want to create nicely formatted report files in LabVIEW, use the report generation tools and pick an output file format that is suitable for what you want to display (e.g. html).
If you want to display your data in a plain text indicator, you would need to do two things:
use a fixed-width font (e.g. courier)
Format all fields with a fixed widh of padding characters.
For a tabular front panel indicator, you should use a table. You can write the header strings into the table header.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • 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

  • How can I write a 1d array of cluster with 3 elements to a file?

    Hi,
    I have to make a "Power spectral densities" analyse from my waveform data. The results from this VI is an array of cluuster with 3 elemments. Now I want to write this array of cluster with 3 elements to a file. And later it must be able to use this file with EXCEL!!
    thanks

    Hello schloronzo,
    make a for loop feeded with your array. Inside the for loop unbundle
    the cluster, "format into string" the 3 values, adding the result to
    the ones before and collect them in a shift register. Then save the
    resulting string to a txt-file. If you make a good format string then
    Excel is able to read your txt-file (use tab a separator and CR/LF
    after each 3 values aka "csv format").
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Write an 1d-array of cluster with 3 elements

    Hi,
    I have to make a "Power spectral densities" analyse from my waveform data. The results from this VI is an array of cluuster with 3 elemments. Now I want to write this array of cluster with 3 elements to a file. And later it must be able to use this file with EXCEL!!
    thanks

    Hi
    I found some outer Forum entries about this topic.
    Look at this links:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=49553&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=170&message.id=51526&requireLogin=False
    I hope this helps
    Manuel

  • Writing data to spreadsheet with time stamp

    Hi
    I am in the process of making a data logger using FPGA DMA FIFOs to read analog inputs into a real time host vi. This vi then queues the data to a second, lower priority loop. It is my goal that at this stage the data will be written to a spreahseet somehow with a usec-accurate timestamp as the first column, and all relevent column headings etc
    I have uploaded my project as a zip for your viewing.
    Thank you all for your help!
    Attachments:
    HS DAQ.zip ‏656 KB
    HS DAQ.zip ‏656 KB

    Have you tried using the Get Date/Time in Seconds to return a timestamp for your data which you could then build into an array with your data?  You could then write this data to a spreadsheet file if you like.
    Kind Regards,
    Robert Ward
    Applications Engineer, NI

  • How can I get the data array from SQL Server Database?

    Hi,
    I can write a data array(2D)into a table of my SQL Server Database. The data array was writen to a column with image type. I know a data array is transformed a binary string when writing into database, but I dont know how to get the data array when I fetch the binary string from database.
    My question is:
    How to transform the binary string into data array? which vi's should I use? I have tried unflatten from string but failed.
    Any response is appriciated.
    Red

    happyxh0518 wrote:
    > I can write a data array(2D)into a table of my SQL Server Database.
    > The data array was writen to a column with image type. I know a data
    > array is transformed a binary string when writing into database, but I
    > dont know how to get the data array when I fetch the binary string
    > from database.
    >
    > My question is:
    > How to transform the binary string into data array? which vi's should
    > I use? I have tried unflatten from string but failed.
    In order to use Unflatten from string you first need to Flatten it
    before writing it. Also depending on the database driver, the returned
    data may actually not be binary but Hexadecimal encoded ASCII which you
    would first have to decode to binray.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Can I select when do i want to write my data into a file?

    What I want is like,
    When I click a button as ON then only it goes an writes the data into a spreadsheet.
    Now i have made the bolllean so that it will show TRUE when you have to write...but if FALSE nothing should happen...
    and I cant see any option in Write to Spread Sheet function for it..
    So can you help me out with what should I do
    Solved!
    Go to Solution.

    You put the Write to Spreadsheet file in a case structure.
    I would recommend looking at the online LabVIEW tutorials
    LabVIEW Introduction Course - Three Hours
    LabVIEW Introduction Course - Six Hours

  • Writing CAN data to a spreadsheet or word processing file.

    Hi. I need to know how I can write CAN data to a spreadsheet or word processing file. I have a vi that reads information from a CAN device and I need to write everything that is read to a spreadsheet or word processing file. Also I'm getting an error message using a vi that uses the frame API to write and read frames. It happens when I change the read or write queue value. Right now they are set at 100 each and when I change them just a little(even by 1) there is an error. Thanks in advance.

    I would recommend against writing DIRECTLY to Excel, while the CAN vi is running, the MSOffice interface is too slow to be doing while the CAN vi is running. There are 2 different ways you can get around this problem though.
    1. When you receive a CAN frame you want to log, write it to a buffer of some kind in Labview (this could be a string buffer wired to a shift register, it simply adds the new data to the end of the buffer) then when your VI closes, it writes the string data to an excel worksheet.
    2. You could log the data to a text file, if you use the Write File.vi (in the File I/O pallette) you can quickly write data to a file if it is done correctly. DO NOT use the VI's on the first row (Write to Spreadsheet.vi and Write Characters to File.vi) because they will be too slow, they open the file, write data, and then close the file each time they run, which takes too much time.
    As for changing the buffers, you can do that, if you change the buffers at the time you call ncCANConfig, if you change the buffers after that you will get an error.

  • Having trouble converting array to spreadsheet string, storing the file and coverting back to array with complex numbers

    I am working with a network analyzer. I have arrays made of 5 columns the first consisting of an integer and the next four consisting of complex numbers. I am converting the array into a spreadsheet string and then saving the file using the write characters to a file VI. That seems to work well as when I open the file in Excel all the data is there. However when I try to reverse the process, open file and convert back to array, I loose some of the data. Specifically the imaginary parts of my complex numbers are all going to zero. I have narrowed down the problem to be in the conversion from spreadsheet string to array and vice versa. I
    think the problem may be with the 'format' input to the VI. I do not have an adequate resource for this so I am not sure what to put in to accomplish my task. Any takers?

    Hi Biz
    I don't think there is a direct way of converting a complex number to a
    string, so when you convert the array to a spreadsheet string, the
    numbers would be converted to real data.
    However, you could try separating the real and imaginary parts using the
    "Numeric: Complex to Re/Im" function, and then store these - either in
    separate files or in adjacent columns/rows in the same file. Then, when
    you read in the data again, use the "Numeric: Re/Im to Complex" function
    to put the two "halves" together.
    If you actually want Excel to interpret the numbers as imaginary, then
    you'll probably want to create a string for each complex number of the
    form "Re + Im*i" (after separating the Re and Im parts), by using
    "String:Format into String" with 2 numeric inputs and the format string
    "%f+%fi".
    Reading the data back into Labview then would require splitting the
    string into the 2 pieces by using "Stringcan from String" with 2
    numeric outputs (smae precision as original numbers specified by the 2
    Default Value inputs) and the same format string "%f+%fi", and then using
    the above-mentioned "Numeric: Re/Im to Complex" function. It worked for
    me, so if you can't follow what I am describing, send me an email and I
    can email you what I did (LV 5.1.1).
    Paul
    Biz wrote:
    > Having trouble converting array to spreadsheet string, storing the
    > file and coverting back to array with complex numbers
    >
    > I am working with a network analyzer. I have arrays made of 5 columns
    > the first consisting of an integer and the next four consisting of
    > complex numbers. I am converting the array into a spreadsheet string
    > and then saving the file using the write characters to a file VI. That
    > seems to work well as when I open the file in Excel all the data is
    > there. However when I try to reverse the process, open file and
    > convert back to array, I loose some of the data. Specifically the
    > imaginary parts of my complex numbers are all going to zero. I have
    > narrowed down the problem to be in the conversion from spreadsheet
    > string to array and vice versa. I think the problem may be with the
    > 'format' input to the VI. I do not have an adequate resource for this
    > so I am not sure what to put in to accomplish my task. Any takers?
    Research Assistant
    School of Physiotherapy, Curtin University of Technology
    Selby Street, Shenton Park, Western Australia, Australia. 6008
    email: [email protected]
    Tel. +61 8 9266 4657 Fax. +61 8 9266 3699
    "Everyone who calls on the name of the Lord will be saved." Romans 10:12
    "For all have sinned and fall short of the glory of God, and are
    justified freely by his grace through the redemption that came by Christ
    Jesus." Romans 3:23-4

  • Write array to spreadsheet string

    Hi,
    I have 3 numeric arrays and 1 string array.  I am try to use the function write array to spreadsheet string.  What is the easy way to do this, since I have both numeric and string, I can't create a 2d array directly?
    Yik
    Kudos and Accepted as Solution are welcome!
    Solved!
    Go to Solution.

    It depends how you want the file to store the data.
    Attached is an example of two methods mentionned above.  You can change the formatting so that you have the data on the same line or different lines.
    There are many solutions depending on exactly what you want to accomplish.
    --- didn't expect to see so many replies so quickly ---
    Most people recommend converting the numeric array to string array first.  I offer an alternative   or a choice of both.. 
    Attachments:
    exampleOfWriteDiffArrayToSprdsht.png ‏28 KB

  • Write 1d array of cluster with 2 elements to file

    HI!
    I'm new at LabView so I hope the question is very simple to you:
    I am using a waveform graph to display several measurements.
    Now I want to save these Measuremens. The data are stored in 1d array of cluster with 2 elements.
    What is the easiest way to do this??
    Thanks

    If you are already using waveforms you can simply wire right up to "Write Waveforms to File.vi" in the Waveform palette under Waveform File I/O.
    Daniel L. Press
    PrimeTest Corp.
    www.primetest.com

  • [Bug?] X-Control Memory Leak with Large Data Array

    [LV2009]
    [Cross-posted to LAVA]
    I have found that if I pass a large data array (~4MB in this example) into an X-Control, it causes massive memory allocations (1 GB+).
    Is this a known issue?
    The X-Control in the video was created, then the Data.ctl was changed to 2D Array - it has not been edited in any other way.
    I also compare the allocations to that of a native 2D Array (which is only ~4MB).
    Note: I jiggled the Windows Task Manager about so that JING would update correctly, its a bit slow, but it essentially just keeps rolling up and doesn't stop.
    Demo code attached.
    Cheers
    -JG
    Unable to display content. Adobe Flash is required.
    Certified LabVIEW Architect * LabVIEW Champion
    Attachments:
    X Control Bug [LV2009].zip ‏42 KB

    Hi Jon (cool name) 
    Thank you very much for your reply. We came to this conclusion in the cross post and it is good to have it confirmed by LabVIEW R&D. Your response is also similar to that of my AE which I got this morning as well - see below:
    Note: Your reference number is included in the Subject field of this
    message. It is very important that you do not remove or modify this
    reference number, or your message may be returned to you.
    Hi Jon,
    You probably found some information from the forum. The US engineer has gotten back and he said that unfortunately that's expected behaviour after they have conducted some tests and this is what he replied:
    "X Controls in the background use events structures. In particular the Data Change Event is called when the value of the XControl changes (writing to the terminal, local variable, or value change property). What is happening in this case is the XControl is getting called to fast with a large set of data that the event structure is queuing the events and data that a memory leak is produced. It is, unfortunately, expect behavior. The main work around for the customer in this case is not call the XControl as often. Another possibility is to use the Synchronous Display Property to defer updates to the Xcontrol, this might slow down a leak."
    He would also like to know if you can provide with more details how you are using the Xcontrol, perhaps there is a better way. Please refer to the link below for synchronous display. Thank you.
    http://zone.ni.com/reference/en-XX/help/371361G-01/lvprop/control_synchronous_display/
    In my application I updated the X-Control @ 1Hz and it allocated at MBs/s up to 1+GB before it crashed, all within a few hours. That is why I called it a leak. I am really worried that if this CAR gets killed, there will still be an issue lingering that makes using X-Controls a major problem under the above conditions. I have had to pull two sets of libraries from my code because of this - when they got replaced with native LabVIEW controls the leak when away (but I lost reuse and encapsulation etc...).
    Anyways, I really want to use X-Control tho (now and in the future) as I like all other aspect of them. If you do not consider this a leak, can a different #CAR be raised that may modify the existing behavior? I offer the suggestion (in the cross-post) that the data be ignored rather than queued? Similar to Christian's idea, but for X-Controls. Maybe as an option?
    I look forward to discussing this with you further.
    Regards
    -Jon
    Certified LabVIEW Architect * LabVIEW Champion

  • How to realign elements of an array? Working with old Dynamic Data consumers

    Hello,
    I've got some code which was written with DAQ assistants years ago.  I'm trying to use tasks and arrays for my producer now for speed and efficiency, but I'm stumped on one thing.
    The consumers were written to have the data in a certain order - there's even a VI in there that selects certain elements and sends them to specific outputs.  I previously took care of this with a simple VI that split the dynamic data, wired them to different order terminals, and then set it back to dynamic;  Screenshot attached.
    Is there a structure like this for array where you can break out all the array elements, reorder them and insert constants, and then put them back into the array?  What this ends up feeding is a subvi that's an array builder which converts the DD to array and then reroutes it.  Seems almost like what I'm trying to do could be done there, but it's a bit confusing to me.
    Thanks in advance.
    Still confused after 8 years.
    Attachments:
    realign.jpg ‏166 KB

    Hi Ralph@NES,
    One thing I have done before for this is create a mapping array and a for loop to reorder the elements in your data array. Take a look at the example VI I've attached. If you know exactly where you want everything, you just need to go into the mapping array and set the index destination for the corresponding data. Hope this helps.
    Paul C
    Paul C
    Applications Engineer
    National Instruments
    Attachments:
    Reorder Array.vi ‏9 KB

  • How to show a data in Higher fonts with write statement

    Hi.
    how to show a data in Higher fonts with write statement
    I want to show a statement in large fonts with write statement.How can I do that.
    write : 'Company Address'.
    Regards
    Mave

    Mave,
      I would precribe you to use the FORMAT options available with the WRITE Statement.
    Because this allows us to differentitate between the HEADIngs and the LINEs in the report.
    Here u go dear:
      http://help.sap.com/saphelp_47x200/helpdata/en/9f/db9e7135c111d1829f0000e829fbfe/frameset.htm
    Thanks
    Kam

  • Write data to .txt file with formatting

    Hi,
    I am trying to read data from serial port and write it on to a .txt file. I am able to write onto the file but it has got no formatting. What I would ideally like to do is, read the data from serial port, take only some parts of it and write on to the text file with proper formatting. Also, I would like to use the same file to append data each time. I am also having issues setting the pointer to EOF. I would like to append to end of file.
    This is my sample data
    18:33:23 02/10/10 28.32             0 LAC     0.378 mg/dL    0000\
    18:33:23 02/10/10 28.32             0 GLU       102 mg/dL    0000
    that is being read from the serial port. From this I would like to take only columns 1,2,3,5,6 and write onto the .txt file.
    Can someone provide some pointers? I'm using Labview 6.1
    Thanks,
    Sukanya

    If you know what "charecters" you don't want it is pretty easy. A little more difficult when they are unwanted only in certain places in the string. There is a remove whitespace function in the string functions palette. There is also a search and replace function in the "additional string functions" subpalette, that can be set up to find all instances of a char and replace it with something else, an empty string if you want to just delete it/them from your string.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

Maybe you are looking for