I have a list of text items that have been extracted from a Dataset. I want to Export these to a text file Unfortunately, when I export the file I get not just the text, but the FullForm.
I create the list thus:
output = Style[Text[#], LineIndent -> 0] & /@ Normal[pQuestions]
The formatting is actually irrelevant, it was just me experimenting, but I include it in case it is relevant. Executing
output
in the notepad, just shows the text, and that’s what I want.
However, when I export the file thus:
Export["pQuestions.txt", output]
The file contains:
Style[Text["Loreum Ipsum etc etc"], LineIndent -> 0]
What am I doing wrong?
Cheers
Andy
Andrew,
Not sure what Normal[pQuestions] evaluates to. Assuming it is a list of strings
list = {"one", "two", "three"};
Export["list.txt", list];
FilePrint["list.txt"]
(*
one
two
three
*)
Mapping Style[Text[#], LineIndent -> 0] over the list results in a list of expressions, which is why it is not working as expected
Style[Text[#], LineIndent -> 0] & /@ list // InputForm
(* {Style[Text["one"], LineIndent -> 0], Style[Text["two"], LineIndent -> 0], Style[Text["three"], LineIndent -> 0]} *)
Thanks Rohit,
That makes sense. I was getting confused about how to produce a clean output. I discovered that if I saved as a pdf rather than text, I got closer to what I want.