LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion of Array of Strings to Array of numbers

Okayyy, Thank You

I have attached the csv file where i am going to get the data and my current state of the VI

Download All
0 Kudos
Message 11 of 19
(893 Views)

Two ways :

1. If all of the data being read from file is numbers, read it numeric format rather than string. This can be done by choosing the file data format in the Read Delimited Sreadsheet.vi (The polymorphic VI selector)

2. The string format data read can be converted to numeric by using Fractional string to number function found under String ---- Number/String conversion on functions palette.

 

I hope this helps

0 Kudos
Message 12 of 19
(888 Views)

Hi Ranga,

 

your VI would work when you would debug and correct it…

 

  • A CSV file uses a delimiter char - and you must set the correct char so LabVIEW will correctly separate the "cells" of your CSV file! The default char to be used is a TAB (as noted in the LabVIEW help!), but your CSV file uses the comma instead. Btw. the comma is also correct because of CSV = "comma separated values"…
  • You need to select the correct rows when you want to get correct data! Your VI indexes rows 38&40, but your CSV file contains data in rows 19&20…
  • You need to set correct index values in your FP array elements! Your default value here is 500, but your CSV file only contains a low amount of data. A better default value for those index vales would be zero to see the first data items!
  • As LabVIEW 2D arrays are "rectangular" all rows will have the same size of columns! So you don't need to get the array size twice for both indexed rows…
  • Use AutoCleanup in the block diagram - and on the frontpanel, too. No need to scatter all items all over the frontpanel, most of them out of view (for a FullHD screen)…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 13 of 19
(882 Views)

Maybe you would want to search the first column for "Curve Data" (without leading spaces, there are some similar fields with leading spaces), then read the following rows as DBL.

 

Here's one simple possibility. See if this can give you some ideas.

 

altenbach_0-1641659591906.png

 

 

0 Kudos
Message 14 of 19
(878 Views)

Okay guys ,

Thanks for replies.

I tried all the solutions given and couldn't find the solution.

 

Hence I have attached the original data file and the VI I have been trying

In excel file, There is 20,000 data split into two rows(Row 20 &21), I want to draw waveform with this 20,000 data.

While I read this excel file from LabView I am getting it in a String array and I want to convert it into Numeric array to draw Waveform graph and perform calculations.

For this I tried an VI and couldn't get it done.

I will attach my Excel File and VI.

Please help me with this guys...

Thank you

Download All
0 Kudos
Message 15 of 19
(850 Views)

Hi Ranga,

 

your file is using UTF16 encoding:

(Notepad++ screenshot)

 

Don't do this!

Create a CSV file directly from Excel and don't touch it with any other text editor!

Then use ReadDelimitedSpreadsheetFile to read the data…

Best regards,
GerdW


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

Hi Ranga,

 

this is what I get after converting your UTF16-CSV file to an ordinary ANSI-CSV file using Notepad++:

Best regards,
GerdW


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

Actually that Excel File is Created by another software. So there is no option to change the settings over there.

I am automating the reading the excel file. 

So Is there any other option I can do it in LabView to get the waveform using numeric array 

0 Kudos
Message 18 of 19
(835 Views)

Hi Ranga,

 


@Ranga2 wrote:

Actually that Excel File is Created by another software. So there is no option to change the settings over there.


Then that "another software" does not comply to standards. You should correct that "another software"…

 


@Ranga2 wrote:

So Is there any other option I can do it in LabView to get the waveform using numeric array 


You need to convert from UTF16 to ANSI first - before converting this file using LabVIEW functions…

Best regards,
GerdW


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