Estoy tratando de crear un servicio macOS usando Automator para extraer anotaciones en PDF y obtener la información en un archivo de Excel.
Puedo obtener con éxito las anotaciones de un PDF y exportarlas a un archivo de texto. Pero si trato de analizar la misma información en un nuevo archivo de Excel, toda la información se pega en una sola celda.
¿Cuáles serían los pasos correctos en Automator para tener cada línea de texto en filas separadas de Excel?
Suponiendo que conoce los conceptos básicos de Automator... Cree un flujo de trabajo con estas acciones:
En la acción de AppleScript, copie y pegue lo siguiente:
on run {input, parameters}
set delimitedList to paragraphs of (input as string)
set myExport to ""
do shell script "touch /tmp/myFile.csv"
repeat with myLines in delimitedList
set myLineExport to ""
set AppleScript's text item delimiters to {" "}
set listItems to every text item of myLines
repeat with eachItem in listItems
set myLineExport to myLineExport & "\"" & eachItem & "\","
end repeat
set myExport to myExport & myLineExport & "
"
end repeat
write_to_file(myExport, (POSIX file "/tmp/myFile.csv" as alias), false)
return POSIX file "/tmp/myFile.csv" as alias
end run
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
Nota: Puede tener problemas si sus anotaciones contienen comillas, sin embargo , no habrá ningún problema si usa comillas tipográficas.
Puede seleccionar su pdf en el primer aviso.
Fuentes: https://www.macosxautomation.com/applescript/sbrt/sbrt-09.html
Jorge
JBis
JBis
JBis