09-14-2015 02:14 PM
This is probably a simple solution but I'm relatively new to LabView and I've gone brain dead. I have extracted data from multiple instruments during a test setup and formatted into spreadsheet arrays and written to a csv file. However the data is simply formatted into 2 columns (1 for the data name, 1 for data value) which is correct however it's not very appealing or easy to read. An example of what this looks like is attached as Sample.csv.
I've also attached a file called SampleIdeal.csv which is how I would like the data to be arranged. Or even better if I could extract the freq and create a column just for that it would be even better. I'm assuming this has to be done using another string to spreadsheet array but like I said I've gone blank.
The data is written line by line during the test to a txt file which I then read from and convert to csv. I can use matching pattern to isolate the Channel data and assume from there it should be easy to separate into columns but cant figure it out. I've attached the vi I'm using to extract the channel data into individual spreadsheet strings.
Thanks for the help
Paul
Solved! Go to Solution.
09-14-2015
02:19 PM
- last edited on
12-13-2024
05:47 PM
by
Content Cleaner
Array to Spreadsheet String can receive a 2D array as an input. This would allow you to use all of the lovely LabVIEW array manipulation tools to generate a 2D array that matches your Ideal file. This manipulation, you'll have to develop yourself to fit your needs.
An easy way to streamline the process is to create a template that you like and then insert the data where needed.
You may also want to look in to the TDMS file format and use it in conjunction with the TDMS Add-on for excel.
To clarify regarding the 2D array, if you generated an array like below and wrote it to file, it would come out the way you want.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-14-2015 04:02 PM
Thanks for the advice.
I'm trying to create the 2d array. I figured the easist way would be to do a "Read from Spreadsheet File" and create a 2D array of each channels info that way. Then I initialize a 2D array the size that I want. Finally I use insert array to insert my 2D arrays into the newly created array. However this isnt working, the total_array stays empty. Any ideas?
09-14-2015
04:07 PM
- last edited on
05-06-2025
11:47 AM
by
Content Cleaner
Please include a Snippet of your code, so that we can better assist you. It's much easier to play around with your code using a snippet instead of a screenshot.
LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. The Highlight Execution feature is a great way to watch how your application utilizes dataflow.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-14-2015 05:10 PM
Ok got it. I think I've made a bunch of improvements now. The data flow appears to be correct (by stepping through and placing probes I can see the data being filled in proper order). The new 2D array is correctly setup with the data being properly applied to new columns. However...the new array does not fill more than 25 rows. I'm assuming this has something to do with the fact that the first array I insert is only 25 rows so that is the max it is allowing. I thought the insert into array block would add as necessary though?
09-14-2015 05:15 PM
Your assumption is correct. You can also utilize the Build Array node (and probably the Transpose Array node if things get tricky) to generate an array without initializing it first.
THe easiest way to fix the 25 problem is to use an Array Size node or two to figure out how big the array will need to be in the end and initialize it to that. If you go on with Insert Into Array, you may end up with empty array cells on the border. This is okay most of the time, I'm just picky.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
09-14-2015 05:28 PM
Got it thanks! If I initialize an array to the correct size ( I can be fairly accurate because I know how many data points I am reading) then all the data is correct. You're right it may not be the cleanest solution but it will work for what I need at the moment.