Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Return text value of a number

Is there a formula on numbers that would return the text value of a number


Example: 100 = One Hundred

MacBook Pro (Retina, 13-inch, Mid 2014), OS X Mavericks (10.9.5)

Posted on Oct 14, 2014 10:15 AM

Reply
15 replies

Oct 14, 2014 8:01 PM in response to SGIII

I wrote a program for uses on the command line so you can type a list of numbers and it provides a list of words for the numbers:


you can download the application here:

https://www.dropbox.com/s/ambw65mtbsbc6jb/NumWrite.zip?dl=0


To use, download the zip file, then unzip (by double clicking) the file.

This will create a file named "NumWrite"


(NOTE: I just tried my own instructions and realized there is a good chance you will download to the folder "Downloads". If you do this there is also a good chance there are many files in the folder. Create a new folder called NumberWriter, or what ever, and move the zip file into this folder before proceeding)


Open the terminal (in the folder "/Applications/Utilities").


If you are not familiar with the terminal that is ok. The process will seem hard but it is not too bad.


Make sure the window where you unzipped the file is visible and you can see the file you unzipped (the executable... the program).


Once the terminal is launched you should see a command prompt. On my computer is looks like this:

User uploaded file


now change directories in the terminal so the terminal window is using the same folder where you unzipped the executable.

Type "cd " (that is "c" then "d" then space)

now drag the folder from the title bar of the window onto the terminal:

User uploaded file


this wil "drop" the path to the folder where the program is in the terminal. Now hit the return key. now to make sure this work let's get a listing of whats in the folder.

Type: "ls -al" then return

you should see something like:

drwxr-xr-x+ 4 wayne staff 136 Oct 14 21:37 .

drwxr-xr-x@ 4 wayne staff 136 Oct 14 20:26 ..

-rw-r--r--@ 1 wayne staff 6148 Oct 14 21:42 .DS_Store

-rwxr-xr-x+ 1 wayne staff 13996 Oct 14 21:36 NumWrite


Notice the "NumWrite" is listed.


Now try the program. Type:

"./NumWrite 200" then hit the enter key

The "./" means start in the current directory"

you should get:

Proton:Debug wayne$ ./NumWrite 200


200 Two Hundred


Now try:

"./NumWrite 200 2000 20000"

you should get:

Proton:Debug wayne$ ./NumWrite 200 2000 20000


200 Two Hundred

2000 Two Thousand

20000 Twenty Thousand


the list can be as many as 128 (maybe more) numbers separated by spaces.


typing this:

"./NumWrite 3026832517 962356513 13722 866195335984 8 690963576 5501237 8068 619929785 327"


will produce the result:

Proton:Debug wayne$ ./NumWrite 3026832517 962356513 13722 866195335984 8 690963576 5501237 8068 619929785 327


3026832517 Three Billion Twenty Six Million Eight Hundred Thirty Two Thousand Five Hundred Seventeen

962356513 Nine Hundred Sixty Two Million Three Hundred Fifty Six Thousand Five Hundred Thirteen

13722 Thirteen Thousand Seven Hundred Twenty Two

866195335984 Eight Hundred Sixty Six Billion One Hundred Ninety Five Million Three Hundred Thirty Five Thousand Nine Hundred Eighty Four

8 Eight

690963576 Six Hundred Ninety Million Nine Hundred Sixty Three Thousand Five Hundred Seventy Six

5501237 Five Million Five Hundred One Thousand Two Hundred Thirty Seven

8068 Eight Thousand Sixty Eight

619929785 Six Hundred Nineteen Million Nine Hundred Twenty Nine Thousand Seven Hundred Eighty Five

327 Three Hundred Twenty Seven





I hope this helps. You can copy the result from the terminal by selecting the text, the copy, the switch to the target application and paste.


This could also be done as an Applescript if SGIII wants to help. If so I can send the c source as a starting point.

Oct 14, 2014 8:29 PM in response to Wayne Contello

Hello sudz10:

I have uploaded a template that will convert a number from 1 to 999999 into words, to the web site:

http://www.iworkcommunity.com/

Once the moderator reviews it, it will be ready to download as a template zip file. Search for

"number to word conversion" to find it. At least for a while, as a new entry, it should be the first listed.

by mswint

Oct 15, 2014 9:52 PM in response to Wayne Contello

turn my simple script into one that processes a whole column of data in a convenient way.


Here's one (below).


  1. Copy into AppleScript Editor. Save in same folder as Wayne's NumWrite app.
  2. Select the column of numbers in Numbers
  3. Run script
  4. Click once in a Numbers cell and command-v to paste.


It ignores decimals.


SG





try



-- get the values from selected Numbers cells

tell application "Numbers"

set t to front document's active sheet's first table whose selection range's class is range

set vv to "" -- will contain space-separated string of values retrieved from selected cells

repeat with c in t's selection range's cells

set vv to vv & my convertNum(c's value) & " "

end repeat

end tell



-- feed the values retrieved from Numbers to NumWrite, first converting any AS scientific notation

tell application "Finder" to set scpt to ((path to me)'s container as alias)'s POSIX path & "NumWrite"

set r to do shell script scpt's quoted form & " " & vv



-- (NumWrite returns a 2-column tab-separated string: numeral in col 1, words equivalent in col 2)



-- extract NumWrite's col 2 for pasting into Numbers

set str to "" -- will contain return-separated numbers expressed as words

set AppleScript'stext item delimiters to " "

repeat with p from 2 to countr'sparagraphs-- "from 2" skips NumWrite's leading blank line

set str to str & r'sparagraphp'swords 2 thru -1 & return-- skips word 1=the number in col 1

end repeat

set AppleScript'stext item delimiters to ""



set the clipboard tostr

display notification "Click once in a cell and command-v to paste numbers expressed as words."


on error

display alert "Select cells containing numbers,"

end try


to convertNum(aNum) -- converts from AS's scientific notation when necessary

do shell script "printf \"%.0f\" " & aNum

end convertNum

Return text value of a number

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.