1

I need to store long strings from mathematica to a text file.

Unfortunately, mathematica provides long cell entries (input/output) after approx the 70th position with a hidden backslash and a new line character:

/ NL

or hex:

5C 0A

For example, when you write or copy/paste long strings into a text file, the backslash and the newline become visible:

Put[" This ---------------- is ---------------- a ---------------- long ---------------- line", "text.txt"]

The content of text.txt is now 2 separate lines and the backslash is visible:

" This ---------------- is ---------------- a ---------------- long \
---------------- line"

Can this behavior be prevented?

I've tried a lot with:

Text[...], ToString[...], CharacterEncoding -> "...."

I work with Linux and mathematica V13

regards 2stein

2stein
  • 13
  • 3

1 Answers1

3

Put and Get work with Mathematica expressions. The contents of the file generated with Put is not intended to be read/understood by other programs.

You probably want to use Export (and Import if you need to read the data back into Mathematica).

lericr
  • 27,668
  • 1
  • 18
  • 64