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