07-20-2014 03:47 PM
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
07-20-2014 04:10 PM
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
07-20-2014 05:11 PM - edited 07-20-2014 05:24 PM
@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
07-20-2014 05:27 PM
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.
07-20-2014 07:13 PM
Better not be homework...
07-20-2014 08:02 PM
@GabeG wrote:
Better not be homework...
Sure looks like a homework assignment or take-home test to me.
07-20-2014 08:51 PM
Other way..
-Munna
07-21-2014 10:33 AM - edited 07-21-2014 10:34 AM
@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
07-22-2014 06:26 PM
@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.
07-22-2014 07:41 PM
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...