Jump to content

Converting text with digit and suffix to numbers


This topic is 3112 days old. Please don't post here. Open a new topic instead.

Recommended Posts

 I importing a  huge list as text files from FileBuddy which gives me file names, file location and file size fields
Importing the text list in the Filemaker database the "SIZE" field is populated with text so I am unable to sort the sizes as numbers. 

the SIZE field looks as follows: 
EXAMSPLEs
666,73 MB
1,36 GB
432 KB
How to I write a script so the "SIZE" text field can be converted in an integer?
Example of possible results:
if the text field is 921,5 MB the resulting number should be 921500000 
or
if the text field is 2,16 GB the resulting number should be 2160000000 from
or
if the text field is 89 KB the resulting number should be 89000

The syntax in the fields is always the same
digits followed with a space then KB or MB or GB. Some include a ","

Any help highly appreciated

Edited by dkey
editing
Link to comment
Share on other sites

You could try this calculation as the option of auto-entering a calc for that field:

Let([
n = GetAsNumber ( Self ) ;
t = RightWords ( Self ; 1 )
] ;
n * 
Case(
t = n ; 1 ;
t = "KB" ; 10^3 ;
t = "MB" ; 10^6 ;
t = "GB" ; 10^9 
)
)

 

Link to comment
Share on other sites

This topic is 3112 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.