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.

If I print a string to a file it also adds quotation marks to the string. Here is an example:

a = "test \t test"
a >> file
FilePrint["file"]

How can I remove those? And is it possible to use \t for a tabulator?

share|improve this question
    
see OpenWrite[] and WriteString[] –  george2079 Sep 20 '13 at 17:27
    
Depending on your problem, Export offers many formatting options that may be useful. –  Yves Klett Sep 21 '13 at 6:51

1 Answer 1

I think what you may be looking for is the following

a = "test\ntest";
fn = "test";
Put[OutputForm[a], fn];
FilePrint @ fn
test
test

As the documentation for Put states: "Put by default writes expressions in InputForm." So you have to wrap the expression you are writing out with OutputForm.

Note: you could rewrite the above code as

a = "test\ntest";
OutputForm[a] >> "test"
FilePrint @ "test"

but I personally don't use >> -- I have a dislike of it because it uses non-standard evaluation.

Also, I should note that I changed \t to \n only because \n makes for a better demonstration effect.

share|improve this answer

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.