I have a mathematica script computing a list of numbers to high precision (5000 digits) which I would like to input into another program. I am running mathematica from the terminal to generate the file.
If I just ask for the output directly, the file it creates has a lot of superfluous return characters and ">" characters which would be very painful to remove.
If I ask for the output in "InputForm" it is cleaner, but it includes information about the precision which is also painful to remove.
Is there a way to generate the output in a clean way for other uses? Here I simply want to generate a list of numbers (comma separated is fine) in decimal notation. Note that I have to run this in a terminal window since it is a long computation on a remove machine, not to mention that the output is extremely long.
Here is an example file (foo) and example output (foo.out) generated by (math < foo > foo.out)
Input:
Table[N[y[n], 200], {n, 1, 3}];
InputForm[Table[N[y[n], 200], {n, 1, 3}]]
Output:
In[1]:=
In[2]:= In[2]:=
Out[2]= {0.585786437626904951198311275790301921430328124623051926823320262009\
> 26752153789296114961246567235842726498615376908770297507516394414926278\
> 735587850290006416858677733407249440724420004949884721793942853,
> 0.4309644062711508251997185459650503202383880207705086544705533770015445\
> 86922982160191602077612059737877497692294847950495845860657358210464559\
> 31308381667736143112955567874906787403334158314120298990475,
> 0.3292893218813452475599155637895150960715164062311525963411660131004633\
> 76076894648057480623283617921363249307688454385148753758197207463139367\
> 79392514500320842933886670362472036221000247494236089697143}
In[3]:= In[3]:=
Out[3]//InputForm=
{0.58578643762690495119831127579030192143032812462305192682332026200926752153\
78929611496124656723584272649861537690877029750751639441492627873558785029000\
6416858677733407249440724420004949884721793942852989044002839`200., 0.4309644\
06271150825199718545965050320238388020770508654470553377001544586922982160191\
60207761205973787749769229484795049584586065735821046455931308381667736143112\
955567874906787403334158314120298990475498174000474`200., 0.32928932188134524\
75599155637895150960715164062311525963411660131004633760768946480574806232836\
17921363249307688454385148753758197207463139367793925145003208429338866703624\
72036221000247494236089697142649452200142`200.}
In[4]:=
I tried Daniel Huber's suggestion, but the output file I got was different (Full disclosure, I used Export["test.txt", d] instead. I am using Mathematica 12.3.1 Kernel for Linux x86 (64-bit).
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899
86280348253421170679821480865191976`100.
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759
45713821785251664274274661651602106`100.
1.14472988584940017414342735135305871164729481291531157151362307147213776988482607
97836232702754897077020098122305809`100.
wolframscript
command andExportString
format of your choosing. For instance,wolframscript -code 'ExportString[N[Pi, 5000], "CSV"]' > foo.out
or with the corresponding code in filefoo
withwolframscript -file foo > foo.out
$\endgroup$