Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extracting Numeric Data From Text String
Message
De
21/03/2013 12:30:33
 
 
À
20/03/2013 17:02:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01568837
Message ID:
01568938
Vues:
74
Thank You sir, Perhaps I have Did it.
lnLines = alines(laArray,filetostr('1013835681.ps'))
FOR I= 1 TO lnLines
IF 'Service Tax' $ laArray(I)=.T.
lnRowposition = GETWORDNUM(laArray(I), GETWORDCOUNT(laArray(I)) - 1) && The second last word
Endif
ENDFOR
I am Getting my required Value. But Sir, I Did't needed to use ASCAN as suggested in previous posting.

I am asking this just for the information purpose only..

Regards






>Make sure to get the last help! http://vfpx.codeplex.com/wikipage?title=VFP%209%20SP2%20Help%20File&referringTitle=Home
>
>And please study the samples and try them out. To answer your question:
>lnLines = alines(laArray,filetostr('c:\somedir\somefile.txt')) 
>?lnLines && the number of lines
>?laArray(1) && Line 1
>
>
>>I Tried ALINES() But Not able to Get It completely, I saw VFP Help also but van Get it. Can you please Give Example.
>>
>>How wil I determine Array Length ( as it will depend upon the number of Line) Second How will I find "Total Charges In that array ?
>>
>>
>>
>>
>>I already told you how to do this.
>>>
>>>1. Separate the text into separate lines, Alines() is perfect for this.
>>>2. Scan the array of lines built by alines and replace the lines where it's necessary
>>>3. Scan the array and recreate the text as you want it.
>>>
>>>>Sir,
>>>>Actially I need The required Value from The following Text.
>>>>
>>>>w
>>>>G
>>>>195 83 89 83 L 
>>>>g n
>>>>F4 B (Branch)477 84 w
>>>>G
>>>>g n
>>>>F4 B (Bank)353 84 w
>>>>G
>>>>422 109 12 -9 k 
>>>>g n
>>>>F4 B (Cheque/DD)232 101 w
>>>>G
>>>>g n
>>>>F4 B (E-payment)440 101 w
>>>>G
>>>>g n
>>>>F4 B (Credit / Debit Card)327 101 w
>>>>G
>>>>g n
>>>>F4 B (Dated)227 84 w
>>>>G
>>>>g n
>>>>F4 B (Cheque/DD No.)19 84 w
>>>>G
>>>>g n
>>>>F4 B (Cash)157 101 y
>>>>G
>>>>g n
>>>>F4 B (Mode of payment)19 101 w
>>>>G
>>>>404 76 12 -9 k 
>>>>127 109 12 -9 k 
>>>>211 109 12 -9 k 
>>>>305 109 12 -9 k 
>>>>440 76 12 -9 k 
>>>>490 76 12 -9 k 
>>>>85 60 8 -8 k 
>>>>108 60 8 -8 k 
>>>>116 60 8 -8 k 
>>>>93 60 8 -8 k 
>>>>124 60 8 -8 k 
>>>>132 60 8 -8 k 
>>>>319 91 8 -8 k 
>>>>312 91 8 -8 k 
>>>>304 91 8 -8 k 
>>>>296 91 8 -8 k 
>>>>283 91 8 -8 k 
>>>>276 91 8 -8 k 
>>>>263 91 8 -8 k 
>>>>255 91 8 -8 k 
>>>>2 P 29 656 72 -43 k 
>>>>g n
>>>>F1 B (Previous Balance)65 648 y
>>>>G
>>>>g n
>>>>F1 B (=)487 633 y
>>>>G
>>>>g n
>>>>F1 B (+)206 633 y
>>>>G
>>>>121 656 72 -43 k 
>>>>g n
>>>>F1 B (Last Payment)157 648 y
>>>>G
>>>>309 655 72 -43 k 
>>>>g n
>>>>F1 B (Current Charges)346 646 y
>>>>G
>>>>g n
>>>>F1 B (Usage Charges)390 538 w
>>>>G
>>>>g n
>>>>F1 B (Tax)390 507 w
>>>>G
>>>>g n
>>>>F1 B (Discount)390 523 w
>>>>G
>>>>g n
>>>>/F5{/I 9.0 Fn2}b
>>>>F5 B (Summary of )392 597 w
>>>>F5 B (Current Charges)392 587 w
>>>>G
>>>>g n
>>>>F5 B (Amount \(Rs.\))561 597 x
>>>>G
>>>>g n
>>>>F5 B (Total Charges)393 486 w
>>>>G
>>>>0 P 24 196 13 189 L 
>>>>13 196 24 189 L 
>>>>2 P 216 656 72 -43 k 
>>>>g n
>>>>F1 B (Adjustments)252 648 y
>>>>G
>>>>0 P 100 631 28 631 L 
>>>>194 631 122 631 L 
>>>>288 631 216 631 L 
>>>>382 631 310 631 L 
>>>>572 631 500 631 L 
>>>>F3 (HIRA LAL GUPTA  .)31 756 w
>>>>(SUKH NIWAS BHOJPUR .)31 747 w
>>>>(SUNDERNAGAR . DISTT. MANDI \(H.P.\) .  .)31 738 w
>>>>(HIMACHAL PRADESH)31 729 w
>>>>(175002)31 720 w
>>>>(India)31 711 w
>>>>F5 (532.81)565 485 x
>>>>F1 (532.00)145 619 w
>>>>(0.00)238 619 w
>>>>(532.81)339 619 w
>>>>(0.00)564 555 x
>>>>(574.00)565 570 x
>>>>(0.00)564 538 x
>>>>(58.61)565 506 x
>>>>(531.87)42 619 w
>>>>g n
>>>>F1 B (Deposit              1200.00)31 678 w
>>>>G
>>>>g n
>>>>F4 B (Amex)551 68 w
>>>>G
>>>>533 76 12 -9 k 
>>>>g n
>>>>F3 B
>>>>
>>>>
>>>>You can see that after Total Charges there is 486 w, I need to extract 486 if that, secondaly the "Total Charges" in some cases become Total Charges Charged" or Total Chrg. Since there is No uniformity, I am Not able to Extract the Data.
>>>>
>>>>
>>>>
>>>>You can try something like this (I just did it quickly so the regular expression I am sure can be bettered, and you can customize it if there are more lines that you are not showing us
>>>>>
>>>>>
>>>>>
>>>>>local loReg, lcString, loMatches, loMatch, loSubmatch
>>>>>
>>>>>clear
>>>>>
>>>>>text to lcString noshow flags 1 pretext 1 + 2 + 4
>>>>>F5 B (Total Charges)390 478 w
>>>>>F5 B (Total Chg)390 478 w
>>>>>F5 B (Total Chrgs)390 478 w
>>>>>endtext
>>>>>
>>>>>loReg			= CreateObject('VBScript.RegExp')
>>>>>loReg.Pattern		= '.*(\(Total cha?r?g?e?s?\)(\s?390)\s)(\d+)\s?w'
>>>>>loReg.Global		= .t.
>>>>>loReg.IgnoreCase	= .t.
>>>>>loMatches		= loReg.Execute(lcString)
>>>>>if loMatches.Count > 0
>>>>>	for each loMatch in loMatches
>>>>>		loSubmatch	= loMatch.SubMatches.Item(2)
>>>>>		? 'Total charges:', loSubmatch
>>>>>	endfor
>>>>>else
>>>>>	? 'No matches found'
>>>>>endif
>>>>>
>>>>>
>>>>>
>>>>>[Update]
>>>>>
>>>>>By the way, I forgot to say that you should replace the TEXT ENDTEXT with lcString = FILETOSTR('Your File')
>>>>>
>>>>>[Update 2]
>>>>>Just noticed that I called the variable loSubmatch instead of lcSubmatch...
Harsh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform