What is the Scan from string pattern for "match everything" ?
Hello,
Using Scan from string for a while, I know that %s only matches string up to a whitespace. And I also thought %[^] would match everything including whitespaces. But it turned out that it would stop at the closing square brace.
So, what is the real scan pattern for match everything including whitespaces ?
What do you want the Scan From String to end on? Or are you just grabbing the rest of the string? If that is your scenario, then just use the "remaining string" output. It might help if you give a full example of a normal input string and EVERYTHING you want as an output.
Similar Messages
-
I am communicating serially with a chilled mirror device and the input string syntax contains this text: "%RH=<input value>"
I have not been able to figure out how to tell the function that the percent here is not a format specifier. Is this possible, or should I just try to use a different function?
Thanks.
Mitch
Solved!
Go to Solution.Use %% in your format string so that it knows to use the percent literally. So %%RH=%f
EDIT: Darin got one in there ahead of me. It looks like either \% and %% both work.
Attachments:
Example_VI.png 10 KB -
"scan from string" to timestamp doesn't work for 18:00:00 (6PM)
I just found a strange issue in LabVIEW. I hope I'm doing something silly, but I just may have found an unusual bug.
run the snippet below with the following for the input string: 03:00:00,18:00:00,17:00:00
Time converts fine for just about any other time EXCEPT 18:00:00 (6 PM) for which it is returned as 00:00:00 (midnight). If you even add a second to it (18:00:01) you get back the expected result.
Here's hoping I'm not loosing my mind
Matt Holt
Certified LabVIEW Architect
Solved!
Go to Solution.
Attachments:
TimeParseBug.vi 11 KBAs annoying as it may seem, this exact scenario is an abuse of the timestamp. A timestamp is meant to be used for absolute times. And that includes a date. As Ravens Fan already pointed out, the 0 seconds since January 1, 1904 GMT is used in all timestamp display routines to mean the canonical invalid timestamp and hence the timestamp control displays the default string indicating the actual date/time format rather than a specific date/time.
If you need an absolute timestamp, for instance because you do want to have a local time indication, although the date is not relevant, adding an offset of 86400 to all values would fix it once and for all. Now the timezone offset can't cause the timestamp to reach 0 ever, even if you reside west of GMT, and it will be fine (until you start to do timestamp arithmetic that involves subtraction of relative timespans, then you would have to make the offset big enough that this will never get an issue). The current date would serve as a nice offset for that, which would be MattH's last suggestion. Nice to see that the Scan from String routine actually does use the passed in timestamp as default value and only replaces the values it is configured to parse.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Hi Everybody,
I'm trying to use LabView to
process some data. The data, although it was collected via labview,
has been written out to csv file format. I have been able to
successfully open the file and use the search split string function to
remove the "header" from the data stream. Now I'm trying to parse the
header to extract some pieces of the info that is there. I'm trying to
do this with the Scan from String VI.
So
far I've been able to retrieve the Specimen ID from the first line of
the header by setting the format string input of Scan from String as
"Specimen ID ,%s", which works just fine. Problem is, when I
adjust
the format string to include the next piece of data I want, I
inevitably get an Error 85, which is a failed scan. In fact, I
get an err85 every time I try to extract something from after the
second line. I've attached a VI in which I cut and pasted an
example header string in as a string constant and an example of how I'm
trying to extract the values. I've tried playing around with
spaces and different formats, but get the err85 no matter what I do
(unless I extract the first line). I have a hunch that it has
something to do with the EOL marker, but no idea how to work around it.
A search of posts here show that a lot of people have issues with the
scan from string vi, but nobody I could find had this exact
problem. I've also considered using the spreadsheet spring to
array function, but because I have a mix of commas and EOLs it doesn't
seem to work either. HELP! I really don't want to have to write this
over in VBA/Excel.
Thanks,
Turk
Message Edited by YoungTurk on 07-29-2005 10:36 AM
Attachments:
Scan.vi 12 KBYou should probably parse it line by line (See attached, LabVIEW 7.1)..
The attached example shows one possibility to get all the Items and values out. Not all values are strictly numeric so you would need to adapt the code a little bit. (This is just a very rough 1 minute draft).
You might want to cosider to extract all values into a cluster for further processing, Have a look at the example posted in this thread . It can be easily adapted to read the values in the proper format (DBL, I32, Date, String, etc.) depending on the item name.
Good luck!
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ScanMOD.vi 30 KB -
How do I avoid Error 85 in Scan From String scanning VISA read buffer?
I have encountered an Error 85 with my Scan From String VI. I have a timed
loop to read data from a device (flowmeter) using a serial port. This device takes
periodic measurements and sends the reading which contains a numerical value to the serial port COM1. It cannot be read continuously, and the period
between measurements may vary, so I decided a timed loop would be better than a while loop.
The VI begins with VISA Configure Serial Port and then
goes to a VISA Write which sends the message to the device to begin
taking measurements. After this, the device usually says "TAKE FLOWMETER READINGS" to the terminal, thereafter only sending numbers. Then begins my timed loop containing VISA Read. I
am taking the read buffer two places.
First, I am taking it to an Array to Spreadsheet String with the
Format String %.3f, as was in the Write to Text File example. Then I am
using Concatenate Strings with this string and also a string containing
the System Time. This string goes to Write to Text File, which I have
configured using Open/Create/Replace File outside of the loop.
Second, I am taking the read buffer to a waveform chart. I thought
it would be a good idea to use Scan From String to convert the string
into a DBL which I am then sending to the waveform
chart.
I am not sure if the initial "TAKE READINGS" message is giving me an error. I was able to get one reading saved to my text file from the device.
Also the format string for my Scan From String is %.3f
I am getting the Error 85 at the Scan From String only sometimes.
When this happens, there is no data being written to the text file. But
other times, I get data and it writes to the text file just fine (but
rounds to nearest whole number).
Any help would be greatly appreciated! This serial port device has been giving me a lot of trouble.Is this what you mean? Did I wire the shift registers correctly?
I didn't know if you meant to Concatenate before Scan From String or Concantenate before or after VISA Read?
Message Edited by YeungJohn on 11-20-2008 03:48 PM
Message Edited by YeungJohn on 11-20-2008 03:49 PM
Attachments:
SerialShiftVI.JPG 87 KB -
Scan from string with %g - result not accurate
I am trying to use the "Scan from String" VI to convert a string into a number. I am using "%g" as the format specifier. The conversion is only grabbing the first six significant digits, yet I need it grab all significant digits. Is there a real limitation here? What could I do to solve this issue?
I have attached a simple VI to demonstrate what I'm seeing.
Thanks,
Joel
Attachments:
Scan_from_String_Example.vi 7 KBIt is because the display format for your numeric indicator is set for 6 significant digits. Adjust the display format for the indicator and you will see that the other digits are there.
-
Why am I getting error 85 from 'scan from string' VI?
Data is in CSV format from an Excel spreadsheet. It may be an empty string but I compare the data to an empty string and, if is empty, then I input the string constant '0' to the 'Scan from String' VI. I'm using 3 probes to try to debug this.
The 1st probe is at the output of an 'Index Array' VI which extracts the element of interest from the array loaded from the spreadsheet file. The probe declares it's type as 'string' and the probe content is blank. I assumed that this means 'empty string'.
The second probe is at the output of an 'Equal' VI which compares the data described above with the empty string constant "". The result is False. Why is this? How do I tell what the CSV data is? If the probe is blank can it be a Null character or NaN or is it interpretted as a blank string? The Excel file has all fields defined as 'text.
The third probe is also blank.
When the data is interpretted by the 'Scan from String' VI it fails. I also have the default pin wired to a double constant with a value of o. Shouldn't this be used by the VI in the event the VI can't interpret the string passed to it?
Thanks for any help,
Frankfr@nk wrote:
The second probe is at the output of an 'Equal' VI which compares the data described above with the empty string constant "". The result is False. Why is this? How do I tell what the CSV data is? If the probe is blank can it be a Null character or NaN or is it interpretted as a blank string? The Excel file has all fields defined as 'text.
Yes, it can be a Null character. NaN is something else. To really see what's there you can place an indicator and then change the display mode of the string indicator to Hex Display Mode.
You have not indicated what your format string is. Why don't you upload your code along with your data. Just out of curiosity, what are you using to read the file? Are you using Read From Spreadsheet File? -
Hello.
I work with LV 7.1, with the I Modul of PDA.
It doesn't work me 'Scan From String'. I have not found any contradiction because the pda doesn't accept it.
Does somebody know which the cause can be? As I can substitute it?
Thank you.
Greta
Attachments:
scan from string.JPG 6 KBHello Greta
The Scan from string function is supported in LV PDA but with some restrictions. The help file for LV PDA tells us:
'The Format Into String function and the Scan From String function do not support changing the numeric separator (such as %#;). The Scan From String function does not support wildcard matches.'
You are changing the numeric separator and this is not supported.
Hope this helps
BelenS -
Scan from string and extract string between delimiter
Hello,
Basic questions. Is it possible with the scan from string regular expression to extract the string that are within the specified delimiters. Here is an example:
\\Name of folder 1\Name of folder 2\Name of folder 3\File Name
Can the scan from string output the following by specifying the right regular expression:
Name of folder 1
Name of folder 2
Name of folder 3
File Name
I have tried \\\\%s\\%s\\%s\\%s but the %s stops at the first white space.
Thanks,
Michel
Solved!
Go to Solution.RavensFan suggested the appropriate function for your requirement, however you can also use an alternative, which is 'Spreadsheet String To Array'.
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT. -
Interesting scan from string error
Got an interesting (and hopefully easy) issue with scan from string. VI and back panel image attached. Open it or make it and try to run it and let me know if you get an error too. Am I doing anything wrong?
(BTW, ignore the %d in the scan from string. You can change those to %f or %g and it still burps)
Message Edited by mlang on 07-21-2008 09:04 AM
Attachments:
ScanFromStringError.JPG 27 KB
ScanFromStringError.vi 14 KB"JB" <[email protected]> wrote in message
news:[email protected]..
> Wiebe@CARYA a écrit:
> Try "%[^,],%d,%d,%d". %[^,] scans all characters that are not ",".With
this unique format specifier for Format Into String and Scan from String, an
error will appear if the input string contains a comma or is empty (the last
case is also true with the original code). Distinct specifiers may be needed
to avoid this.
Yes, comma's might not be the best seperator. It will also fail if the
numbers use "," as seperators (as is often the case in Europe)...
But the same can be said for any seprator... If you use tabs as seperator,
the parsing will fail if the string contains tabs...
Regards,
Wiebe. -
Strange "Scan From String" to Timestamp Error
hi,
i am trying to parse my time-string into a Time Stamp with "Scan From String" but i get some strange Error(1).
The Code:
The Error:
can anyone confirm? do i have an error in my parser-string?
is it possibly related to this Bug
461196
Scan From String VI returns Error 1 with "%t" as the format string input
http://www.ni.com/product-documentation/52151/en/
that should be fixed?
my labview version is
LV 2014 Service Pack 1 -- Version 14.0.1 (32bit)
with the RealTime addon (but the code in question was not run on RT)
thanks for your time.
Solved!
Go to Solution.Why do you have the square brackets around the scan from string format string? They are not there when you generate the timestamp string so it will fail when trying to convert it back as they are expected to be there.
Certified LabVIEW Architect, Certified TestStand Developer
NI Days (and A&DF): 2010, 2011, 2013, 2014
NI Week: 2012, 2014
Knowledgeable in all things Giant Tetris and WebSockets -
Get string inside brackets - Using Scan from string
I have a very basic question here. I would like extract a portion of a string which is inside brackets (Example: I work with [National Instruments]). In the string I only want to extract National Instruments, I do know logic to extract by finding the brackets and extracting them. But I am interested in using the Scan from string or possibly any other primitive in one shot. Please suggest if anyone has any idea, I am really not use to the format specifiers. I got this link for reference but I am not able to figure out a solution.
The best solution is the one you find it by yourself
Solved!
Go to Solution.Hi,
I cannot say that it is the best solution, I use two Scan From String functions instead of one but it does work, so far ;-)
I use Characters in set.
I could not attach VI so FP is below.
Duri -
Scan from string to timestamp not working
Hi,
I have a problem with the "Scan from string".
The format string "%<%H:%M:%S%ds%bs%y>T"
works for the input string "11:12:1322sJans2010"
but doesn't work for the input string "11:12:1322sFebs2010"
The only difference is the month (Jan or Feb). I got know idea why!
Could anyone help me?
Regards,
Marcelo
Attachments:
dateString.vi 6 KB
date.PNG 5 KBBoth work for me in LabVIEW 2009; perhaps this was a bug in 8.6 that's been fixed?
Also, is it possible your operating system is running a different language, in which Jan is the abbreviated form of January but February is something else? -
Trying to use the Scan from String VI to break apart a string. How does one get it to accept strings with blanks embedded?
Solved!
Go to Solution.
Attachments:
Untitled 2.vi 7 KB -
Regular expression for Scan from String
I am trying to pick out three numbers with pattern $number1:number2:number3# from a stream, for instance 8.559509#$-1.686432:-2.427051:-7.281153#$-6.160924:-1.763356:
So far, I use "Scan from String" with Format string "$%f:%f:%f #". However I don't know how to ignore/delete the items before $. Would you like to help me with that? CheersYou know that your sequence of numbers begins with the $ and ends with the #, so you can separate them into groups first, then separate each number out.
Bill
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Maybe you are looking for
-
Install BI Tools with paid VS2008 Pro in workstation and paid Sql Server 2008 R2 in server?
My workstation has VS2008 Pro (paid) and Sql Express (free); our Windows Enterprise server has SQL Server 2008 R2 RTM (paid). In other words, my workstation may not have a paid version of the sql server DB, but our server does. Is there a possibility
-
OIM p.1.0.1 update to 9.1.0.2 bp018 error
Hi, I have updated oim 9.1.0.1 to 9.1.0.2 and then applies bp018 patch to it. After applying the bp018 patch i am not able to create,update user's or not able to run any workflow(custom connector's) for provisioning. And i am getting this error
-
Program has to display the calender year with certain dates highlighted
The program will have a selection screen with the parameter option for empid (Provide F4 help) and select option for Start Date and End Date (Provide the F4 functionality to the date fields.) 2. When the user Executes the program, the program
-
contacts won't open. have switched off ipad, synced, and rest....nothing seems to work!! please help!
-
EMET 5.1 and F-Secure 5.1 do not get along; do other AVs?
This regards a freshly built (by me) W-7 HP 64-bit PC. After I installed Office 2010 and all updates, I installed F-Secure IS. Then I tried to install EMET 5.1. However, every time I try to start IE11, I receive an "EAF mitigation" error which preven