Combining Text in Automator for Excel import.

I'm attempting to create an automator workflow that will string some text together so that it can be imported into an Excel worksheet. Here's my workflow so far.

• New Text File
Creates file temp.txt

• Run AppleScript
Opens file temp.txt

• Get Specified Text (specified text below)
Read Today
Read Tomorrow
Read This Week
Read This Month

• Filter Paragraphs (needed so the text is not treated as one big line of text and is displayed in the next step correctly)
Return Paragraphs that are not empty

• Choose from List (all 4 items displayed correctly, all selected by default)
Select one item

• Set Contents of TextEdit Document (temp.txt) (append)

• Get Specified Text (specified text below (a semi-colon))
;

• Set Contents of TextEdit Document (temp.txt) (append)

• Get Specified Text (specified text below)
keywords go here

• Set Contents of TextEdit Document (temp.txt) (append)

• Get Contents of TextEdit Document (results below)
"
Read Today
;
keywords go here"

(Once I get this part working, I will add a URL onto it also).

So, all my content has arrived here, but on three different lines. But because it is on three different lines, it does not import into Excel correctly. I can't concatenate this using the usual AppleScript method because I would have to declare these items as variables. I've tried various ideas, but I cannot get the three above to append to one line, like this…

Read Today;keywords go here

without manual intervention, which sort of defeats the reason for trying to automate this.

I hope I've explained this well enough that it makes sense.

Any help or ideas are appreciated.

MacBook Pro, Mac OS X (10.6.2)

Posted on Jan 9, 2010 7:50 AM

Reply
4 replies

Jan 9, 2010 8:15 AM in response to MattSh

I'm having a very hard time understanding what you are trying to do and the problem. why is it that you can't concatenate the results using applescript? what you get in the end are 3 lines of text as separate objects, right? you can certainly concatenate those. please clarify what exactly you get in the end and what you want to do with it.

Jan 9, 2010 9:39 AM in response to V.K.

Well, it is good to know that it can be done in Applescript, though I have not found a way to accomplish this. All examples I have seen (Googling and AppleScript 1-2-3 book) use set statements using static strings, and then concatenating those statements together. Since my values are dynamic, those examples don't help.

What I have to work with are these lines of text in a new document.

Read Today
;
keywords go here

The text will vary from run to run.

What I need to end with is… (for use in Excel, import text files action)

Read Today;keywords go here (line1 & line2 & line3)

So, I don't know how to proceed from here, unless I can do something like set var1 to line1 of temp.txt, set var2 to line2 of temp.txt, etc.

Jan 9, 2010 10:02 AM in response to MattSh

well, try this applescript action on the end
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}
set output to ""
repeat with par in paragraphs of item 1 of input as text
set output to output & par
end repeat
return output
end run</pre>

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.

Combining Text in Automator for Excel import.

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