LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using scan from string

As Darin noted, if you just write the string that you read directly to the file then you should be able to open it in Excel by simply specifying commas as the delimiter. Instead of using Write to Spreadsheet File just use Write Text File.

0 Kudos
Message 11 of 20
(2,891 Views)

What do you intend to do with the -.----- values?  You could leave them alone (they would have to be strings), you could convert to DBL and they would default to 0.0, or you could do some checking and change them to NaN for example.

 

How would you like the time formatted for your program?  Timestamp (you would need the date), seconds since midnight (DBL) or individual values for Hour, Minutes and Seconds?

 

As for writing to an "Excel" File, I would still recommend writing the string to the file directly.

0 Kudos
Message 12 of 20
(2,894 Views)

the -.--- valuse are pressure readings. I need to get the values compare to a setpoint and then control a pump. I am trying to use scan from string and get the values. Also am using the format as %[%f:%f:%f],%f,%f,%f,%f. After I run the vi it returns me an error saying

 

Error 85 occurred at Scan From String (arg 1) in pressure sensor.vi

Possible reason(s):

LabVIEW:  Scan failed. The input string does not contain data in the expected format.

 

Also string subset is not working as the value is -ve sometimes and its changing the count. So it is returning , to the excel sheet.

 

As far as the timestamp, we have decided it is not important to write it to an excel sheet but would be better if we could.

Thanks,

Raghu

0 Kudos
Message 13 of 20
(2,871 Views)

If you really want to parse this and not use Darin's suggestion, the easiest way I know to do this is a two stage process:

 

  1. Use Spreadsheet String to Array with the delimiter set to comma and the array type to string array to separate the individual elements.
  2. Use Index Array to get the individual elements and parse them as necessary.

You will then need to convert them back into a string and back into a tab or comma separated text file for Excel to read.  Alternately, you can use the ActiveX interface to directly create an actual Excel file.

 

Message 14 of 20
(2,859 Views)

What do you want it to look like when you send it to Excel? I guess that seems to be the easy question that no one has asked.

 

Tim
GHSP
0 Kudos
Message 15 of 20
(2,846 Views)

I might not be clear while posting my problem.Here is the situation

 

I am receiving the data from a pressure monitor in the format hr:mm:ss:, -.---,-.---,-.---

-.--- is not constant. it might go to -ve -.---  or even to -.-- format .

I need to used the values -.--- further in my program to make changes to my process and also to store in a file to retrive the data at a later point. So I wanted to copy in a excel file.

 

So my question is 1) how to get each  -.--- value as a separate indicator and 2) how to send each value to an excel or text file.In an excel file I would like to have each value in a separate column.

 

Hope this explains my situation more clearly,

 

Thanks,

Raghu

0 Kudos
Message 16 of 20
(2,839 Views)

You can use the following regular expression to break up your data.

So you want to write your data to excel?

I would recommend simply building an array and saving it as either "comma delimited" or "tab delimited" text.

You can do this using the "write to spreadsheet file" VI.

 

22431iDFC1728B52B8D687

Cory K
Message 17 of 20
(2,816 Views)

Cory, your example will not work if only one of the "-.----" location is a number. It's not clear whether or not this can happen, but the impression seems to be that it can.

 


@raghu670 wrote:

I might not be clear while posting my problem.Here is the situation

 

I am receiving the data from a pressure monitor in the format hr:mm:ss:, -.---,-.---,-.---

-.--- is not constant. it might go to -ve -.---  or even to -.-- format .

I need to used the values -.--- further in my program to make changes to my process and also to store in a file to retrive the data at a later point. So I wanted to copy in a excel file.

 

So my question is 1) how to get each  -.--- value as a separate indicator and 2) how to send each value to an excel or text file.In an excel file I would like to have each value in a separate column.


 

Let's review, shall we?

 

For (1) : IF it's possible that only SOME of the "-.---" values can actually be numbers then use DF Gray's approach:

 

IF all of the "-.---" values can be numbers then Cory's approach can be used.

 

 

For (2): As noted many times, simply feed the string directly to a Write Text File function. You do not need to convert anything, you do not need to split anything. Simply write it out to a text file:

Download All
Message 18 of 20
(2,798 Views)

Hi guys,

Thanks for your help.I have tried all your suggestions but came across Match Pattern vi and used it. Now I can save my file as .xls and each data is going into a new cell.It might not be pretty but works for me as I want.

 

Now I will shift my focus to report generation to create excel workbook.

 

Thanks again for all your suggestions

Raghu

 

 24218i54D8B0E07934DCBB

0 Kudos
Message 19 of 20
(2,688 Views)

 


@raghu670 wrote:

Hi guys,

Thanks for your help.I have tried all your suggestions but came across Match Pattern vi and used it. Now I can save my file as .xls and each data is going into a new cell.It might not be pretty but works for me as I want.


 

 

Well, if you insist on doing things the hard way, go right ahead...

0 Kudos
Message 20 of 20
(2,679 Views)