LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from excel

Hi All,

I am trying to read data from excel and i am facing some issue while reading data from column A in excel. when i try converting spread sheet data into 2D array using read spread sheet delimeter vi, the data present in A column separated by comma are coming in two separate column in labview output of 2D array.

 

for example:data present in cell A1 i.e "1,2" in excel are coming as "1" in column 1,"2" in column 2 of 2D array output.

 

Do anyone know how to get data 1,2 data in the same cell of 2D array output?

0 Kudos
Message 1 of 4
(889 Views)

Hi Sahan,

 

so you set the comma as delimiter between your values - and now you wonder why certain data, separated by comma, is placed in different array elements?

 

The comma is used to separate "cells" of your spreadsheet contents, and ReadDelimitedTextFile does exactly what you told it to do!

When there are commas inside the spreadsheet cells then you should use a different delimiter char! (I usually use a semicolon…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(885 Views)

When you say "Data from Excel", do you mean from a file with the extension .xls or .xlsx, a file that was probably created by the Microsoft program "Excel", or a text file, with the extension .csv (otherwise known as a Comma-Separated Values file), which has little to do with Excel (except that the company that makes Windows gives such files an Icon that resembles the Icon Microsoft uses for true Excel .xls and .xlsx files)?

 

You cannot read true Excel files with Read Delimited Spreadsheet (Excel can read them, of course).  You did not attach either the File in question (so we can see for ourselves) or the code you used to try to read it.

 

It is also unclear what sort of "answer" you are trying to get.  For the example file you showed in the picture (I get upset when posters present "pictures" of the problem, rather than the actual files which have a lot more useful information!) had Row 1 with cell A1 having "1,2" and cell B1 having "3".  What is the desired output?  Do you want an array with three elements, "1", "2", and "3", or an array with two elements, "1,2" and "3"?  Do you want the elements to be strings or numbers?  [Important, because the next two rows have both numbers and letters].

 

Bob Schor

0 Kudos
Message 3 of 4
(865 Views)

If you're going to use commas in your data then don't use comma delimiter for your read instructions.  You can save your files as .txt which are tab delimited for reading your columns correctly.  You will likely need to use some of the string array functions such as match pattern function to get the formatting the way you want it.

0 Kudos
Message 4 of 4
(856 Views)