Jump to content

My spreadsheet-friendly file writer:


Recommended Posts

Description of my VI (Labview 8.5):

Based on the MooreGoodIdeas VI Process Array Elements, which is a subVI of Write Anything.vi. This VI writes a 2D array along with optional row and column headers to a spreadsheet file. A more-than-two dimensional array will create a folder or hierarchy of folders, with each page of the array written to a separate file.

Includes Freeware from Moore Good Ideas, www.mooregoodideas.com. Do not remove this line.

Headers as Variant can be an array, or cluster containing arrays. The VI will attempt to match the number of elements in each header array with the number of columns, then the number of rows, etc., in that order. Thus if you wish to label both rows and columns and you have the same number of rows and columns, you should list the column headers in the first array and the row headers in the second. If no dimension size matches to the size of one of your header arrays, the VI generates a warning and does not use the header.

post-4616-124639526621_thumb.png

The best way to see how this works is to play with test_rw_array.vi, which you should probably locate together with Write_Array.vi from the zip file. That is, in folder Write_Array Folder\Common\InputOutput\FileArrays.

I haven't yet written a corresponding "Read_Array.vi" yet. I'd like to see what y'all think first.

One of the weird features(/bugs) about my VI is that if you want to include headers for your filed array, my VI automatically matches the size of your headers (which you feed as a cluster of 1D arrays) to corresponding sizes of your main array. Let's say you've got a 5 X 3 X 7 array, and you write a single header with 3 elements. Then my VI knows you meant these to be row headers. On the other hand, let's say you've got a 5 X 3 X 3 array, and a single 3-element header. This is where it gets weird: my VI will assume you want column headers. It will start with the lowest dimension, and if necessary work backwards until a matching size is found. Why? Mostly because I can easily see where a user would want only row and column headers for a high-dimensional array.

If I'm crazy, let me know now, before I build on top of this and make it worse.

Write_Array Folder.zip

Link to comment

Thanks Michael. Does anyone have any feeback about the size-matching trick for headers, and the columns-first priority? Should I add an optional control whereby the user specifies which headers match to which dimension? Should I just be "normal" and try to match your first header array to the first dimension possible, rather than the last? Note that you can always prevent confusion by supplying headers for every dimension, even if some headers are just blank strings.

Also, if you specify headers for pages, volumes, etc., these go into the file names and folder names. Thus, when you write a 4-D array without headers, you get folder names like array_0, array_1, etc., and file names like array_0_0.log, array_0_1.log, etc. When you write the same array WITH headers, you get folder names like array_0_4{[pt}]5Volts, array_1_3{[pt}]5Volts, etc., and files names like array_0_0_10mA.log, array0_1_20mA.log, etc. Maybe this isn't good? Instead, the folder containing the pages of the array could contain a text file listing the headers for each file (i.e. each page), and the next-higher-level folder could contain a text file listing the volume headers. Then I wouldn't have to replace special characters like the decimal point.

Link to comment
  • 2 weeks later...

Here's an update. For the case where you have headers for dimensions > row,col, I create a separate file containing those. This file is in the lowest-level folders (i.e. each volume's folder has a copy of the file). Also, the first cell with a header contains some info about whether there are both row and column headers, or whether only one dimension is labeled.

test_rw_array Folder.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.