Hallo outdoor262
vielen Dank für deinen Beitrag / deine Frage in der Apple Support Community.
Anbei ein funktionales AppleScript (mit Quellenangabe) zum Import von CSV-Files in Numbers. Ich habe einzig das Trennzeichen von "," nach ";" für DE geändert, ggf. sind weitere gewünschte Anpassungen erforderlich.
(*
Source: https://discussions.apple.com/thread/252341079?answerId=254431186022#254431186022
old: set AppleScript's text item delimiters to ","
new: set AppleScript's text item delimiters to ";"
*)
(*Use maximum number of text items to set number of columns, rather than add extra columns on the fly.
I assume this really is a csv file and thus set text item delimiters to , *)
set csvFile to (choose file of type "CSV")
set csvText to read csvFile
set AppleScript's text item delimiters to ";"
set rowCount to (count paragraphs in csvText)
set maxColumns to 0
repeat with x from 1 to rowCount
set columnCount to count text items in paragraph x of csvText
if columnCount > maxColumns then set maxColumns to columnCount
end repeat
(*
Create new Numbers document, delete default table, create new table
based on text item (column) count and paragraph (row) count in csvText.
Set format of all cells to Text:
*)
tell application "Numbers"
activate
make new document at front
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 csvText and place them in the correponding cells in the newly created table
*)
repeat with nextRow from 1 to rowCount
set columnCount to (count text items in paragraph nextRow of csvText)
repeat with nextColumn from 1 to columnCount
set nextValue to text item nextColumn of paragraph nextRow of csvText
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
Kopiere den o.g. Code, füge ihn in die App Skripteditor (macOS) ein und starte das Skript.
Ich hoffe, dass ich damit bereits weiterhelfen konnte und wünsche einen schönen Abend / eine gute Nacht.
Liebe Grüße!