LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scan a number from a string with thousands separators

I've been retired for a few years and am a little rusty. I've been scraping records from my local government and need an elegant way to scan dollar amounts from strings scraped from pdf files. The amounts can range from hundreds of dollars ($241) to millions ($2,123,456.78). Here are a couple of strings I have to parse. They are building permits: site location, NEW Single Family Residence, permit #, Valuation, Fee, applicant, date.

 

3448 N YAVAPAI STREET NEW SFR BLD19-0212 $116,264.53 $3,951.61BIG RED CONSTRUCTION08/29/2019

5065 W CAMELBACK LOOP KGMN NEW SFR BLD19-0341 $7,152.00 $203.06Mohave Shadez08/05/2019

 

I made a cluster of each of the elements of the string and then parse the string to load the elements into the cluster. I am having trouble with the dollar values.

get Value and Fee.png

This only works if the values have one comma. I need a general solution for 0, 1, or 2 commas.

0 Kudos
Message 1 of 6
(339 Views)

Not sure what we can assume about the structure of the input string, but here's a quick attempt.

"Assuming the $ character occurs exactly twice and always before a number, etc.)

 

I am sure it can be optimized further. You talk about cluster, but I don't see a cluster.

 

altenbach_0-1749424672560.png

 

 

0 Kudos
Message 2 of 6
(319 Views)

Thanks for the fast reply. I took the easy way out and removed the commas. That made it simple.

0 Kudos
Message 3 of 6
(313 Views)

Yes, my code will remove all commas for the two numbers following the dollar characters.

0 Kudos
Message 4 of 6
(302 Views)

I immediately jumped to using a regular expression:

jcarmody_0-1749461655596.png

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 6
(248 Views)

@Viper wrote:

 

I need a general solution for 0, 1, or 2 commas.


My regex matches 0, 1, 2 or more commas OR decimal points!  That makes it not "work", but you've got other problems if the data has more than one decimal point.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 6
(220 Views)