I'm using Applescript to generate CSV files in Text Wrangler. What character do I need to append to my lines in Applescript for Text Wrangler to see it as a line break? "¬" is not working. Perhaps an ASCI code? Help greatly appreciated.
\n
set theList to {"apple", "orange", "banana"}
set AppleScript's text item delimiters to return
set theTextList to theList as text --change the list to text using 'return' to separate items
set AppleScript's text item delimiters to ""
do shell script "echo " & quoted form of theTextList & " > ~/Desktop/output.csv"
For Windows its two ASCII characters: CR (13th character) and LF (10th character). Everyone else uses LF. As long as you don't need Windows you can just use LF.
You should be fine with adding:
whenever u need it. Note the non-standard slash. It allows you to type a character that normally is impossible.Code:\n
\¬
Could you not just use the word "return" in your AppleScript? Here's a snippet to show what I mean:
Code:set theList to {"apple", "orange", "banana"} set AppleScript's text item delimiters to return set theTextList to theList as text --change the list to text using 'return' to separate items set AppleScript's text item delimiters to "" do shell script "echo " & quoted form of theTextList & " > ~/Desktop/output.csv"
Thanks for response. I remember "return" now. The Applescript part of your code, up to the last line will certainly work exactly as shown in my script. Not knowing Unix commands : ( , I don't fully understand the last line. I should start to learn Unix (and brush up on Applescript)
Don't worry about the Unixy bit, that's just me writing the CSV text to file. You could do it using AppleScript's native "write file" but personally I find it fiddly and prefer to use a little 'do shell script'. If you want to do it natively using AppleScript then you can find more info here.
http://www.macosxautomation.com/applescript/sbrt/sbrt-09.html
Good luck!
Wili text Wrangler (or other text editor) recognize LF as a new line?