LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string to 2d array to excel sheet

I think i missed it out I am really sorry. I only want the values with the header like

x       y      z

1.0  4.0  2.5

1.1  4.1  2.6

1.2  4.2  2.7

1.3  4.3  2.8

1.4  4.4  2.9

 

Also vi you posted cannot be viewed as i have labview 2012 and you are using a higher version.

Anyways,thanks for the guidance but please it would be good if u just tell the steps as i m a beginner i want to learn things and indeed your previous post helped me a lot.

0 Kudos
Message 11 of 19
(815 Views)

Hi,

   No problem. This task as mentioned before is more common and even easier. The attached vi should do it. I saved it down to LV2010. The basic principle is to loop over the string, use match pattern to find the index of the "=" character. Use the index to scan out the number just after the "=" and store it in an array. After each loop, you use the previous index as the starting point for match pattern so you don't find the same "=" character twice. When match pattern can't find an "=" it spits out -1 as the index. Every loop you check to see if the index is below zero and stop if it is. The array is one dimensional, so we find the size and divide by 3 to get the 2D dimensions (12 -> 4 x3) and reshape the array. Then use array to spreadsheet string to get a comma separated string of only numbers. Concatenate a header and then write it to a file.

0 Kudos
Message 12 of 19
(795 Views)

Thanks for the entire help!
Two things i just want to know, why write to text file is used in case structure, can't it be used without case?
Other thing is that "Frac/Exp string to number" box is being fed with the ofset of match pattern, its job is to prompt when the match pattern occurs?

0 Kudos
Message 13 of 19
(778 Views)

Hi,

   The case structure around write file is not necessary, but if the user clicks cancel, it prevents an error dialog being generated since the selected path will be empty. It's good practice to handle the cancel button on a file open dialog, but not necessary. Match pattern finds the next "=" and outputs the offset into the string where it was found. This then tells Frac/Exp string to number where to start looking for the next number.

 

Keep coding!

0 Kudos
Message 14 of 19
(765 Views)

@GabeG wrote:

Hi,

   The case structure around write file is not necessary, but if the user clicks cancel, it prevents an error dialog being generated since the selected path will be empty. It's good practice to handle the cancel button on a file open dialog, but not necessary. Match pattern finds the next "=" and outputs the offset into the string where it was found. This then tells Frac/Exp string to number where to start looking for the next number.

 

Keep coding!


It's as necessary as it can get without actually being "necessary."  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 15 of 19
(740 Views)

@GabeG: thanks for the explanation!

 

i have been working around with the vi, to get data continuous data string (same format as previously posted ) from serial and converting into .csv file.
I have succeeded with your help, but one problem occurs everytime i have to select the path to save the .csv file. i have tried options to append the file till the process is running but failed. could you have a look and tell where the problem lies.

0 Kudos
Message 16 of 19
(720 Views)

Hi,

   This one is interesting. At first glance it looks like it should be working correctly, though there are some issues like writing the header each loop. I started to fix it up a little, but couldn't get it to work. That's when I noticed that another write text file had become hidden from view. This happens when you have a vi inside a structure and you reduce its size. The extra write file had no file path wired to it and so it was constantly resorting to the write file dialog. Attached are a pair of screen shots that show this. I also fixed up the vi a little bit more and added a couple comments.

Download All
0 Kudos
Message 17 of 19
(710 Views)

Ooops! Now i couldn't find that one.
Thanks for all the input of yours i now get a better understanding and learning.
though i couldn't understand the wroking of the outlined box in the attached file. could u explain that?
Also i have ran the vi successfully and its working with live serial string data. Now my next target is to log the data at a on interval of 5 seconds that i will do my self and making a graph of the x vs. y after logging is done.

THANKS again!

0 Kudos
Message 18 of 19
(685 Views)

Hi,

   That is just a three input "and" gate. It reads, only write to the file if (the user wants to) and (file refnum is good) and (there is data available to write).

0 Kudos
Message 19 of 19
(665 Views)