Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extracting Numeric Data From Text String
Message
De
20/03/2013 07:09:03
 
 
À
20/03/2013 06:57:38
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:
01568844
Vues:
37
You must separate each sentence or each line. For lines you can use alines(), for sentences you can use getwordnum(lcText,lnX,'.'). To work efficiently you should always separate the job into smaller units, and create functions for things you must do several times.

>Sir, But Since I will be extracting the same from a .txt file which is full of Data, How will I get tcString ?
>
>
>>>Suppose I want to Extract 478 from the given string. I am using the following code
>>>
>>>
>>>lcStr="F5 B (Total Charges)390 478 w"
>>>lnPOS = At("Total Charges",lcStr)
>>>WAIT WINDOW SUBSTR(lcStr,lnpos+18,3) && Displays 478
>>>
>>>
>>>The same gives me the required Value.
>>>
>>>However, in certain cases I get string as "F5 B (Total Chg)390 478 w" insetead of "F5 B (Total Charges)390 478 w", in another instace I get "F5 B (Total Chrgs)390 478 w".
>>>
>>>I need 478 from the above irrespective of whether it is Total Charges/Total Chrg/Total chg etc.
>>>
>>>Similarly, I have In some Cases "Service Tax" and in other string as "Service Tax New"
>>>
>>>Kinldy Guide How to Extract the required value with accuracy in such cases
>>>
>>>Regards
>>>Harsh
>>
>>
>>lparameters tcString
>>lnWordNum = getwordcount(tcString)
>>If Getwordnum(tcString , lnWordNum) = 'w'
>>   lnWordNum = lnWordNum - 1 
>>Endif
>>return val(getwordnum(tcString, lnWordNum ))
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform