LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview String and Array help

Solved!
Go to solution

Hi,

 

I'm currently running into an issue of converting some Numeric and String data into an array then exporting it to a .csv. The issue arises when I take my data (29.0;1.1;30;STRINGNAME) and it through the [Spreadsheet String to Array.vi]. It will put it into 4 columns, 29.0   1.1   30   0, with the STRINGNAME being converted to a 0. I need the first 3 to be numerical and the last one being a String. Part of the reason I'm doing this is because it needs to be a 2D array going into a [Write Delimited Spreadsheet.vi]. 

 

For more specifics if needed, I'm using a case block with several different enumerated states, which is the "string" value i've converted from enum. This state needs to be logged next to the data pulled from a Keysight Electronic Load, which is giving out the Voltage/Current/Power from the Read Visa. The data is being build into a .csv file which essentially needs the keysight values logged next to which state it was in. I have a few blocks that basically dump data every so many samples, so I need to keep track of which line of the array it is at. The [Search and Replace String.vi] is used to get rid of the Line Feed Constant the Keysight puts in line with the data it sends. This is where I'm looking to take this string of data (in the format of [volt;curr;pow;STRING]) to put into a csv file. 

 

Any help or thoughts would be appreciated. Still newer to Labview and I'm sure I'm probably overlooking a simple block that does this, and I'm just not recognizing it. 

 

AliasLP_0-1741642790736.png

 

0 Kudos
Message 1 of 11
(398 Views)

@AliasLP wrote:

I'm currently running into an issue of converting some Numeric and String data into an array then exporting it to a .csv. The issue arises when I take my data (29.0;1.1;30;STRINGNAME) and it through the [Spreadsheet String to Array.vi]. It will put it into 4 columns, 29.0   1.1   30   0, with the STRINGNAME being converted to a 0. I need the first 3 to be numerical and the last one being a String.


Since you are saving the data to a CSV file just use the spreadsheet string to Array function but convert it to a string array.

snip.png

 

0 Kudos
Message 2 of 11
(397 Views)

Alright, so I didn't know there was a way to convert it to a String array, so that's definitely helpful. When plugging this in though, it looks like its cutting off some data now. The numeric values are just the first significant digit, and the first 3 letter of the Stage name. If I apply the Fract/String to Number.vi then I'm back where i started with 0's for the "stage" name.

AliasLP_0-1741645281998.png

AliasLP_1-1741645321643.png

AliasLP_2-1741645530015.png

AliasLP_3-1741645591554.png

 

 

 

0 Kudos
Message 3 of 11
(379 Views)

We really (really!) cannot debug truncated pictures.

0 Kudos
Message 4 of 11
(375 Views)
Solution
Accepted by topic author AliasLP

This is the string you want to convert to an array, 29.0;1.1;30;STRINGNAME

 

It is separated by semicolons, are you using that as the delimiter? How are you writing to your CSV file? The following works fine for me. (You should post your VI backsaved for an earlier version.)

 

snip.png

 

EDIT: Do you use commas for a decimal separator?

Message 5 of 11
(369 Views)

@AliasLP wrote:

Alright, so I didn't know there was a way to convert it to a String array, so that's definitely helpful. When plugging this in though, it looks like its cutting off some data now. The numeric values are just the first significant digit, and the first 3 letter of the Stage name. If I apply the Fract/String to Number.vi then I'm back where i started with 0's for the "stage" name.


Do you miss the decimal part in the text file or is it an Excel import thing?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 11
(321 Views)

Here's a stupid idea: why not just save the semicolon data straight to your file. I have no doubt Excel can still use that. The alterative I would do it use Search Replace String to replace the semicolons with commas and just write that data to a text file. This will save you a lot of steps.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(300 Views)

While I get this comment, giving you the full scope wouldn't do you any good unless you had the Keysight EL34143A. So i gave the replicable section and talked about which area is giving the issue, which sounds like you didn't actually read, but just wanted to flame at someone who didn't give a complete VI or full scope picture. I know I'm new to labview, but that doesn't mean I'm not new to giving the appropriate data in most cases. And with the help of someone else in the thread, it looks like they knew exactly the section I'm having issues with and were able to replicate the 3-5 blocks that were needed. 

0 Kudos
Message 8 of 11
(285 Views)

Thanks for replying again. The data from the keysight is separated by semicolons and I do have it as the delimiter. I'm using the buildpath.vi to write to csv along with some header information, which I don't think is the issue (but could be?) as previously before trying to add in the string, it gave the data in the format I was looking for. What you posted also works for me, when I create it as a stand alone, so I think this is definitely the right solution. I'm going to mess around with it a bit more, as the stand alone does export the way I need it to but this doesn't. Thanks again for your help on this!

0 Kudos
Message 9 of 11
(281 Views)

I'm using a buildpath and listed the filename as Characterization.csv

It was working properly up until I needed to add in the string next to the data values. (I try building one step at a time and adding on stuff as I'm still learning Labview in general), so I don't think its the way I'm saving the data. I bet i'm being dumb and just not using the right conversions at some point in my architecture.

0 Kudos
Message 10 of 11
(280 Views)