Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a list of points (e.g. {1.2,0.4}) which I export to a file using

Export[fileName, list];

I want to add a line before the end of file. For instance instead of ending the file with

1.236677 4.64567567
1.236677 4.64567567
1.236676 4.64567567

ending like

1.236677 4.64567567
1.236677 4.64567567
1.236676 4.64567567
# a blank line here

I tried appending {}, {,}, "" to the list, but none of them added a blank line.

I need this because xmgrace is not parsing the last line of the exported mathematica file: it expects a blank line before the End of File.


EDIT: As pointed out in the comments by Kuba and Pinguin Dirk, appending "" works on Windows XP (and probably others.) I'm using OS X.

share|improve this question
1  
maybe something like: Export["foo.txt", Append[list, ""]]? –  Pinguin Dirk Sep 11 '13 at 9:41
    
I already tried that but it doesn't work. If I use " ", it prints a new line with a white space in it. –  J. C. Leitão Sep 11 '13 at 10:10
    
@J.C.Leitão What OS are you working on? Pinguin Dirk's solution works on WinXP. –  Kuba Sep 11 '13 at 10:22
1  
If all else fails: file=OpenAppend["file"]; Write["\n"]; Close[file] –  Pickett Sep 11 '13 at 10:50
1  
@cormullion, yep, OS X here too, and I too tried "\n". What file type are you exporting to? –  Pinguin Dirk Sep 11 '13 at 12:20
show 3 more comments

2 Answers

up vote 4 down vote accepted

Here, on my OSX the following works

Export["tmp/foo.txt", Append[Range[10], "\n"]]

Mathematica graphics

share|improve this answer
add comment

Try

Export[fileName, Append[list, ""], "Table"]

This should be OS-independent although I cannot check this under OS X.

share|improve this answer
    
Doesn't work with OSX. At least on my 9.0.1 with OSX 10.8.4 –  halirutan Sep 11 '13 at 13:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.