LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing out non-numeric characters in a string

Solved!
Go to solution

It's a LOT easier to eliminate errors at the source than to catch them later!

Bill
CLD
(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.
Humble author of the CLAD Nugget.
0 Kudos
Message 21 of 70
(2,278 Views)

I know that you can't check for every human error, but the most common mistakes for us would be typos, so I want to have some sort of method to check for some of those typos...

0 Kudos
Message 22 of 70
(2,276 Views)

Understand and agree about eliminating errors at the source. But when you have thousands of lines in a csv file to sort through, it's very easy to miss a small mistake like a simple space character in between elements. But LV can be taught what the expected format is, and if the input differs at all, it can parse out the bad data and output the correct. Or is this not possible?

 

If it's not even possible, could I at least check to see if there is bad data in the input, and notify the user that the input data is bad?


Thanks,

SM

0 Kudos
Message 23 of 70
(2,273 Views)

But if you can develop a system of data entry as I proposed above (or ANY kind of system that auto-generates the commands and parameters), you don't need to go through the CSV file to check for typos.  RegEx can get very messy, as you already know, AND I can guarantee that it will just cause more headaches because it will invariably miss something because a human is no longer involved and you won't notice it.

Bill
CLD
(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.
Humble author of the CLAD Nugget.
0 Kudos
Message 24 of 70
(2,268 Views)

RegEx isn't really for error checking, but more for parsing text that was already checked.

Bill
CLD
(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.
Humble author of the CLAD Nugget.
0 Kudos
Message 25 of 70
(2,267 Views)

Ok so any ideas for a good method to check for the errors, then let RegEx parse it?


Thanks,

SM

0 Kudos
Message 26 of 70
(2,265 Views)

I did have the idea of using the dropdown menus/some kind of ring + parameter controls, but it depends on just how many commands you have.  e.g., if it was DOS commands, it's not going to work, but if it's a subset of, say, ten DOS commands, this could definitely work.

 

The menu select way is the most bomb-proof way I can imagine, but as I said, this could be somewhat cumbersome.  Still, some diligent work on the front end could lead to relaxation on the back end.  😉

Bill
CLD
(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.
Humble author of the CLAD Nugget.
Message 27 of 70
(2,258 Views)

So not really sure what you mean by "ring + parameter controls"? Do you ahve any examples?

 

And again, I understand and agree that eliminating errors at the beginning is the easier way, but I have been instructed to do it this way, so I don't really have a choice...

 

Thanks for the help,

SM

0 Kudos
Message 28 of 70
(2,253 Views)
Solution
Accepted by topic author Sman29

Regexes can be part of the solution but here there are cases where you will not have a valid command string. The commands are packets of 3-4-4-2 values, if you have a string where a value is all bad characters as is error 5-6-7 of your error document what value will you use as a replacement? If there is a bas character mixed with a value is just removing these character will give the intended value?

 

In my opinion some typos and formatting can be corrected but with bad or out of range character the command shoud be rejected and a flag rised.

 

As a starting point you can use the following code.

 

parse command string.png

 

Ben64

Message 29 of 70
(2,247 Views)

Hopefully this gives you an idea of what I had in mind?  (It was much easier than what I had explained, actually, since all the data was supposed to be numeric).select command.png

[edit] geez what happened to the wires?  They looked okay when I uploaded it... [/edit]

select command.png

No more danger of typos.  (You can do more checking for ranges and stuff like ben showed.)  This just shows parsing the first group, BTW.

Bill
CLD
(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.
Humble author of the CLAD Nugget.
Message 30 of 70
(2,230 Views)