LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string to 2d array to excel sheet

Greetings,
I am a beginner at labview, tring to explore it. I am stuck in a task as follows
I have a txt file which i want to convert it into array then display it into excel file.

 

Below is the string data in the txt file
x=1.0,y=4.0,z=2.5,x=1.1,y=4.1,z=2.6,x=1.2,y=4.2,z=2.7,x=1.3,y=4.3,z=2.8,x=1.4,y=4.4,z=2.9,

 

I want to convert the above data to an array/excel sheet like below

x=1.0  y=4.0  z=2.5  

x=1.1  y=4.1  z=2.6

x=1.2  y=4.2  z=2.7 

x=1.3  y=4.3  z=2.8

x=1.4  y=4.4  z=2.9

 

Now i know that match mattern would be used to seperate the delimiter ',' but what after then, i m confused in how to progress further.

Please guide me how to solve this task

Regards

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

Hi,

   See the attached block diagram image. I deleted a few parts for you to fill in. The basic idea is to loop through the string and increment a counter every time you find a comma. When you find the third comma, replace it with an end of line constant. Excel should read it as a .csv fine.

 

Thanks,

-Gabe

0 Kudos
Message 2 of 19
(4,278 Views)

@GabeG

thanks for the prompt reply,can u post the vi as i m new to labview wont be able to understand via an image file

0 Kudos
Message 3 of 19
(4,257 Views)

Your data string format is very unusual.  Where did it come from?

 

Most systems will just use a simple comma seperated values.  This means that you won't have the "x=", "y=" and "z=".  You will just have the values serperated by the commas.  Then the new array items will just be in a new line of the file.  Excel will actually just open these files too.  So your data should look like:

1.0,4.0,2.5

1.1,4.1,2.6

1.2,4.2,2.7

1.2,4.3,2.8

1.3,4.4,2.9

 

But back to your setup.  Personally, I would just a Scan From String to find each set of x, y, and z value.  Build the array as necessary.



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 4 of 19
(4,241 Views)

Better not be homework...

0 Kudos
Message 5 of 19
(4,217 Views)

@GabeG wrote:

Better not be homework...


Sure looks like a homework assignment or take-home test to me.

0 Kudos
Message 6 of 19
(4,206 Views)

Other way..

 

-Munna

Munna
0 Kudos
Message 7 of 19
(4,194 Views)

@crossrulz , @GabeG :

its just a sample of the data that actually i will be receiving from PIC MCU via serial.
To understand and gain knowledge regarding how to manipulate data i am working on a sample data
its basically the voltage,current and temp readings,which i will seprate it under their relative headers

0 Kudos
Message 8 of 19
(4,157 Views)

@GabeG :
the solution you posted is correct but the problem is when i m further converting it into array and then creating .csv file to read it on excel.
It shows empty array.
Please look at the vi and tell me should i also be using match pattern box to seperate commas.

Download All
0 Kudos
Message 9 of 19
(4,133 Views)

Hi,

    Going by your original requirements, you want the spreadsheet to display "x=1.0", etc... in the cells. Just to confirm, you don't want values which could be plotted, you want a table with text that has the axis and an equals sign? If that is the case, then you just write the folded string into a text file with the .csv extension and Excel opens it no problems. See attached. If you what you really want is a table of numbers/values, then we have to modify the program a little...

Download All
Message 10 of 19
(4,121 Views)