How to turn off automatic formatting of links in Numbers?

I paste a tab-separated plain text set of email addresses into Numbers and the software adds a live link to every ****** one despite all auto-correction being turned off in settings. Any ideas for stopping this unhelpful behaviour?

Posted on Jul 13, 2024 7:19 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 13, 2024 11:25 AM

I also have a very similar script that will import a delimited file into a new Numbers document with all cells formatted as text. This will import everything into the table unchanged and not interpreted by Numbers. After import you can format columns to "automatic" to turn "numbers" into actual numbers and "dates" into actual dates, etc. while leaving other columns as text.


-- Import Delimited Text File into a New Numbers Document

-- This script reads a user-selected delimited file (comma, semicolon, or tab delimited), creates a new Numbers
-- document, and imports the contents with all cells formatted as text. Once imported, the user can reformat 
-- cells/column/rows to "automatic" or another format so "dates" will be actual dates, "numbers" will 
-- be actual numbers, etc. and leave others as text.

-- The usual/simple way of separating delimited text into "items" by setting the text item delimiter to a comma or semicolon or
-- tab doesn't work in all cases because the file can contain the delimiter within quoted text.  To get around this,
-- the algorithm first converts the file to a "Unicode character 0000" delimited string as it interprets the file and determines
-- which "delimiters" are within quoted text and which are the actual delimiters. 
-- This means that "Unicode character 0000" is an unallowable character in the CSV file.
-- Carriage return is a not an allowed character in the file, even if surrounded by quotes.

-- Written by Badunit, reusing some code from others
-- Feb 4, 2022

set newTID to character id 0 --Unicode character 0000
set oldTID to AppleScript's text item delimiters


set csvFile to {choose file of type {"TXT", "CSV"}}
set csvText to read csvFile

set csvDelimiter to (choose from list {",", ";", "Tab"} with title "Delimiter" with prompt "Choose a delimiter" default items ",") as text
if csvDelimiter = "Tab" then set csvDelimiter to "	"

-- Convert the CSV text to delimited string with the specified delimiter. 
-- First turn it into an array of characters for easy mainipulation.
-- Pad the end with a null for the "quote test" portion of the algorithm.
-- Before converting back to a string, set the Applescript text delimiters to null so that no delimiters are put between characters

set theCharacters to characters of csvText
set end of theCharacters to ""

set i to 1
set openquote to false

repeat while i ≤ length of csvText
	if item i of theCharacters = "\"" then
		if openquote = true then
			if item (i + 1) of theCharacters = "\"" then
				set i to i + 1
			else
				set openquote to false
			end if
		else
			set openquote to true
			
		end if
		
		set item i of theCharacters to ""
	else if item i of theCharacters = csvDelimiter and openquote = false then
		set item i of theCharacters to newTID
	end if
	set i to i + 1
end repeat

set AppleScript's text item delimiters to ""
set newText to theCharacters as string

-- Count paragraphs (rows in spreadsheet) and text items (columns in spreadsheet)
-- Use maximum number of text items to set number of columns, rather than add extra columns on the fly.

set AppleScript's text item delimiters to newTID

set rowCount to (count paragraphs in newText)
set maxColumns to 0
repeat with x from 1 to rowCount
	set columnCount to count text items in paragraph x of newText
	if columnCount > maxColumns then set maxColumns to columnCount
end repeat

--Create new Numbers document with correct sized table
--Set format of all cells to Text

tell application "Numbers"
	activate
	make new document at front
	delay 1
	tell document 1
		tell sheet 1
			delete every table
			make new table at front with properties ¬
				{row count:rowCount, column count:maxColumns, header column count:0, header row count:0}
			set format of every cell of table 1 to text
		end tell
	end tell
end tell

--Loop through paragraphs and delimited items of newText and place them in the correponding 
-- cells in the newly created table.
-- Not sure why but if all of this was in the same "tell application Numbers" block as the code above, it
-- would not count the text items of newText. So it has it's own "tell application Numbers" block.

repeat with nextRow from 1 to rowCount
	set columnCount to (count text items in paragraph nextRow of newText)
	repeat with nextColumn from 1 to columnCount
		set nextValue to text item nextColumn of paragraph nextRow of newText
		tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
			set nextCell to cell nextColumn of row nextRow
			set value of nextCell to nextValue
		end tell
	end repeat
end repeat

-- Clean up. Set the delimiters back to what they were at the start

set AppleScript's text item delimiters to oldTID



5 replies
Question marked as Top-ranking reply

Jul 13, 2024 11:25 AM in response to Badunit

I also have a very similar script that will import a delimited file into a new Numbers document with all cells formatted as text. This will import everything into the table unchanged and not interpreted by Numbers. After import you can format columns to "automatic" to turn "numbers" into actual numbers and "dates" into actual dates, etc. while leaving other columns as text.


-- Import Delimited Text File into a New Numbers Document

-- This script reads a user-selected delimited file (comma, semicolon, or tab delimited), creates a new Numbers
-- document, and imports the contents with all cells formatted as text. Once imported, the user can reformat 
-- cells/column/rows to "automatic" or another format so "dates" will be actual dates, "numbers" will 
-- be actual numbers, etc. and leave others as text.

-- The usual/simple way of separating delimited text into "items" by setting the text item delimiter to a comma or semicolon or
-- tab doesn't work in all cases because the file can contain the delimiter within quoted text.  To get around this,
-- the algorithm first converts the file to a "Unicode character 0000" delimited string as it interprets the file and determines
-- which "delimiters" are within quoted text and which are the actual delimiters. 
-- This means that "Unicode character 0000" is an unallowable character in the CSV file.
-- Carriage return is a not an allowed character in the file, even if surrounded by quotes.

-- Written by Badunit, reusing some code from others
-- Feb 4, 2022

set newTID to character id 0 --Unicode character 0000
set oldTID to AppleScript's text item delimiters


set csvFile to {choose file of type {"TXT", "CSV"}}
set csvText to read csvFile

set csvDelimiter to (choose from list {",", ";", "Tab"} with title "Delimiter" with prompt "Choose a delimiter" default items ",") as text
if csvDelimiter = "Tab" then set csvDelimiter to "	"

-- Convert the CSV text to delimited string with the specified delimiter. 
-- First turn it into an array of characters for easy mainipulation.
-- Pad the end with a null for the "quote test" portion of the algorithm.
-- Before converting back to a string, set the Applescript text delimiters to null so that no delimiters are put between characters

set theCharacters to characters of csvText
set end of theCharacters to ""

set i to 1
set openquote to false

repeat while i ≤ length of csvText
	if item i of theCharacters = "\"" then
		if openquote = true then
			if item (i + 1) of theCharacters = "\"" then
				set i to i + 1
			else
				set openquote to false
			end if
		else
			set openquote to true
			
		end if
		
		set item i of theCharacters to ""
	else if item i of theCharacters = csvDelimiter and openquote = false then
		set item i of theCharacters to newTID
	end if
	set i to i + 1
end repeat

set AppleScript's text item delimiters to ""
set newText to theCharacters as string

-- Count paragraphs (rows in spreadsheet) and text items (columns in spreadsheet)
-- Use maximum number of text items to set number of columns, rather than add extra columns on the fly.

set AppleScript's text item delimiters to newTID

set rowCount to (count paragraphs in newText)
set maxColumns to 0
repeat with x from 1 to rowCount
	set columnCount to count text items in paragraph x of newText
	if columnCount > maxColumns then set maxColumns to columnCount
end repeat

--Create new Numbers document with correct sized table
--Set format of all cells to Text

tell application "Numbers"
	activate
	make new document at front
	delay 1
	tell document 1
		tell sheet 1
			delete every table
			make new table at front with properties ¬
				{row count:rowCount, column count:maxColumns, header column count:0, header row count:0}
			set format of every cell of table 1 to text
		end tell
	end tell
end tell

--Loop through paragraphs and delimited items of newText and place them in the correponding 
-- cells in the newly created table.
-- Not sure why but if all of this was in the same "tell application Numbers" block as the code above, it
-- would not count the text items of newText. So it has it's own "tell application Numbers" block.

repeat with nextRow from 1 to rowCount
	set columnCount to (count text items in paragraph nextRow of newText)
	repeat with nextColumn from 1 to columnCount
		set nextValue to text item nextColumn of paragraph nextRow of newText
		tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
			set nextCell to cell nextColumn of row nextRow
			set value of nextCell to nextValue
		end tell
	end repeat
end repeat

-- Clean up. Set the delimiters back to what they were at the start

set AppleScript's text item delimiters to oldTID



Jul 13, 2024 9:58 AM in response to Badunit

-- Import CSV or Tab Delimited File into Numbers

-- This script reads a user-selected CSV or Tab delimited file and imports the contents of the file
-- into a selected table of a Numbers document starting at the selected cell. 
-- It will add new rows and columns if necessary.
-- If there is a data type that requires special formatting to import correctly, pre-format
-- those cells (or column or row) before importing

-- The usual/simple way of separating delimited text into "items" by setting the text item delimiter to a comma or semicolon or
-- tab doesn't work in all cases because delimited files can contain the delimiter within quoted text.  To get around this,
-- the algorithm first converts the file to a "Unicode character 0000" delimited string as it interprets the file to determine
-- which "delimiters" are within quoted text and which are the actual delimiters. 
-- This means that "Unicode character 0000" is an unallowable character in the CSV or Tab delimited file.
-- Carriage return is a not an allowed character in a CSV or tab delimited field, even if surrounded by quotes.

-- Written by Badunit, reusing some code from others
-- July 13, 2024

set newTID to character id 0 --Unicode character 0000
set oldTID to AppleScript's text item delimiters


set csvFile to {choose file of type {"TXT", "CSV"}}
set csvText to read csvFile

set csvDelimiter to (choose from list {",", ";", "Tab"} with title "Delimiter" with prompt "Choose a delimiter" default items ",") as text
if csvDelimiter = "Tab" then set csvDelimiter to "	"

-- Convert the CSV text to delimited string with the specified delimiter. 
-- First turn it into an array of characters for easy mainipulation.
-- Pad the end with a null for the "quote test" portion of the algorithm.
-- Before converting back to a string, set the Applescript text delimiters to null so that no delimiters are put between characters

set theCharacters to characters of csvText
set end of theCharacters to ""

set i to 1
set openquote to false

repeat while i ≤ length of csvText
	if item i of theCharacters = "\"" then
		if openquote = true then
			if item (i + 1) of theCharacters = "\"" then
				set i to i + 1
			else
				set openquote to false
			end if
		else
			set openquote to true
			
		end if
		
		set item i of theCharacters to ""
	else if item i of theCharacters = csvDelimiter and openquote = false then
		set item i of theCharacters to newTID
	end if
	set i to i + 1
end repeat

set AppleScript's text item delimiters to ""
set newText to theCharacters as string

-- Count paragraphs (rows in spreadsheet) and text items (columns in spreadsheet)
-- Use maximum number of text items to set number of columns, rather than add extra columns on the fly.

set AppleScript's text item delimiters to newTID

set rowCount to (count paragraphs in newText)
set maxColumns to 0
repeat with x from 1 to rowCount
	set columnCount to count text items in paragraph x of newText
	if columnCount > maxColumns then set maxColumns to columnCount
end repeat

--Make sure there are enough columns and rows in the selected table
tell application "Numbers"
	activate
	tell front document's active sheet
		tell (first table whose selection range's class is range)
			set rowstart to address of row of first cell of selection range
			set colstart to address of column of first cell of selection range
			set lastrow to rowstart + rowCount - 1
			set lastcol to colstart + maxColumns - 1
			if row count < lastrow then set row count to lastrow
			if column count < lastcol then set column count to lastcol
		end tell
	end tell
end tell


--Loop through "paragraphs" and delimited items of newText and place them in the correponding 
-- cells in the table
-- Not sure why but if all of this was in the same "tell application Numbers" block as the code above, it
-- would not count the text items in newText. So it has it's own "tell application Numbers" block.
repeat with nextRow from 1 to rowCount
	set columnCount to (count text items in paragraph nextRow of newText)
	repeat with nextColumn from 1 to columnCount
		set nextValue to text item nextColumn of paragraph nextRow of newText
		tell application "Numbers"
			tell front document's active sheet
				tell (first table whose selection range's class is range)
					set nextCell to cell (nextColumn + colstart - 1) of row (nextRow + rowstart - 1)
					set value of nextCell to nextValue
				end tell
			end tell
		end tell
	end repeat
end repeat


-- Clean up. Set the delimiters back to what they were at the start

set AppleScript's text item delimiters to oldTID





Jul 13, 2024 10:01 AM in response to Antony Gordon

The team that wrote the "table import" part of Numbers should be fired. Every last one of them. The manager overseeing that team should be fired for letting all the problems with "table import" continue for year after year after year without fixing any of them. The manager in charge of that manager should be fired for letting that manager get away with ignoring the problem for so many years.


That is what I think of the "table import" so called "feature" of Numbers. It is total trash.


I mashed together some scripts that I have used in the past for importing delimited text files. I was going to post it below but apparently I exceeded the 5000 character limit so I'll post it separately. It imports a delimited file (tab, comma, or semicolon) into an existing table starting at the selected cell. It uses the existing formatting of the table so it also solves the problem of leading zeros being dropped from bar codes, SKU numbers, and other numbers that may have leading zeros. Simply pre-format that column as text or number system. I see, though, that it will NOT import email addresses or web pages as links even if you wanted it to so I guess it is not perfect.


If this works for you, you should be able to make it into a Shortcuts App shortcut so it is easier to use than running it with Script Editor. Let me know if you have any problems with it.



Jul 14, 2024 1:17 AM in response to Badunit

Many many thanks for this. I can't recall ever using Script Editor before so that was something of a novelty. Your first script seemed to run at first but I think it added into an existing Numbers sheet of the same name and looked to be partially successful. After deleting that sheet I re-ran but then just got error about Numbers (I think) being unable to access the file.


The second script though has done the job perfectly. I have two columns of email addresses, none of which is now live, so you have achieved what Apple's engineers have so far unfortunately failed to do.


Again, many thanks for your help.

Jul 14, 2024 1:32 AM in response to Badunit

To explain, for anyone else coming here, this second script does the business. Input file was a tab separated list of email forwarding addresses of the format:


address[tab]address(es) – comma space separated where more than one.


Using Numbers – with all automatic formatting already set to off – to import, or just dropping file contents into an already set up empty table resulted in every address formatted as a live email link. Thanks, Apple – this needs to be fixed!


This second script from Badunit imports the file into two columns with NO added links. Perfect. All I need to do now is set column widths and add a header row.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to turn off automatic formatting of links in Numbers?

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