03-10-2025 04:42 PM
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.
Solved! Go to Solution.
03-10-2025 04:55 PM
@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.
03-10-2025 05:26 PM
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.
03-10-2025 05:37 PM
We really (really!) cannot debug truncated pictures.
03-10-2025 05:53 PM - edited 03-10-2025 05:54 PM
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.)
EDIT: Do you use commas for a decimal separator?
03-11-2025 02:43 AM
@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?
03-11-2025 07:06 AM
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.
03-11-2025 08:53 AM
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.
03-11-2025 09:02 AM
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!
03-11-2025 09:04 AM
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.