LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion of Array of Strings to Array of numbers

Hello Everyone,

I am having a 1D array of string data(10000 values) which contains numbers. I want to convert it to  1D array of numbers to draw Waveform graph and for some calculations also. 

I have tried many inputs from the web source.

Can anyone help me with this???

 

I have attached my VI image.

0 Kudos
Message 1 of 19
(1,786 Views)

read file.png

You are reading the file as string....

Instead of that try to read it as integer or double...


CLD Using LabVIEW since 2013
0 Kudos
Message 2 of 19
(1,779 Views)

@Ranga2 wrote:

Can anyone help me with this???

 

I have attached my VI image.


It really depends on a lot of things that we cannot see from your image:

 

If all data is numeric, you can of course read the file as DBL, but that might not be the case here. Some fields might be header strings, dates, or other types!). You seem to have at least 80 rows and are only interested in two of them, so scanning "everything" as DBL (i.e. >>10000 x 80 fields!) is unnecessary and potentially expensive. Please go with Wiebe's suggestion, operating on your two 1D arrays.

 

Also note that 2D arrays are never "ragged", so your two sizes will always match and only one is really needed.

0 Kudos
Message 4 of 19
(1,728 Views)

I have tried your Idea, but couldnt get the result.

I have attached the front panel and vi image below,

please kindly look into it and help me get the solution

Download All
0 Kudos
Message 5 of 19
(1,703 Views)

Hi Ranga,

 


@Ranga2 wrote:

help me get the solution


When you want us to help you then you need to help us first: by attaching your code and your data file (atleast a smaller section of that file)!

 

From what can be seen on your images your "text file" seem to contain a lot of garbage as there seem to be a lot of additional SPACE (or other) chars.

 

Are you reading some kind of UTF16 text file? Text functions in LabVIEW only like "real text" aka ASCII!

And numeric conversion functions don't like additional chars outside the allowed numeric char range…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 19
(1,701 Views)

Sir, I have attached my VI and data containing excel. 

Here I need to get the Curve data values in the form of waveform graph.

Please help me to get this result.

Thank You

Download All
0 Kudos
Message 7 of 19
(1,693 Views)

Hi Ranga,

 

convert your XLSX file to a CSV file using Excel.

After doing so you can easily use all those "spreadsheet" functions in LabVIEW, including Read/WriteDelimitedSpreadsheetFile…

 

You cannot read XLSX files using functions expecting plain text files!

 

Keep in mind: there is a huge difference between "spreadsheet files" (aka CSV aka delimited text files) and files using a proprietary file format (like MSOffice XLSX)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 19
(1,689 Views)

I tried converting into csv file also and I tried getting the data from csv file and the same happened, I could not convert into numeric array.

Actually the curve data, I mean the excel file is written by another software and it stores all the data in the excel file as string values(the numbers below curve data are in the form of string).

 

The issue is I am calling a string data from excel which contains numbers and I have to convert it into numeric array for calculations and plotting a waveform graph

0 Kudos
Message 9 of 19
(1,669 Views)

Hi ranga,

 


@Ranga2 wrote:

I tried converting into csv file also and I tried getting the data from csv file


Again you forgot to attach the file so we cannot debug your problem.

Please attach that CSV file and the current state of your VI...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 19
(1,657 Views)