Message Boards Message Boards

Change Wolfram Language output while saving it?

Posted 4 years ago

Hello everyone. I have constructed a program which calculates two functions and then proceeds to save them at a .txt file (attached as Sinc_output.txt).

I however have to email this file to someone who doesn't use mathematica, but instead python. They have asked me to do some changes to my output for the sake of compatibility.

My mathematica output looks like this: 12.888765315293599Sinc[0.08377580409572782(0. + t)]Sinc[0.17951958020513104(-65. + u)] -...

I have been asked if I could change it to look like 12.888765315293599Sinc(0.08377580409572782(0. + m.lammda[i]180/np.pi))Sinc(0.17951958020513104(-65. + m.phi[i]180/np.pi)) -...

I would have to swich the brackets of the Sinc for parenthesis and also the variable t for m.lammda[i]180/np.pi and u for m.phi[i]180/np.pi.

For what I have read, there is no way of doing this, but if someone could tell me a way of doing this I would be extremely thankful.

Regards.

Jaime

Attachments:
POSTED BY: Jaime de la Mota
2 Replies
Posted 4 years ago

Hi Jamie,

You can perform string substitutions e.g.

Import["~/Downloads/Sinc_output.txt"] //
 StringReplace[#,
   {"[" -> "(",
    "]" -> ")",
    "t" -> "m.lammda[i]180/np.pi",
    "u" -> "m.phi[i]180/np.pi"}] &
POSTED BY: Rohit Namjoshi

Hi Rohit. Thanks for your answer. It works like a charm.

Regards.

Jaime.

POSTED BY: Jaime de la Mota
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract