I have a text file which I have constructed as
savedXText = ExportString[savedX, "Text"]
savedXText2 =
StringReplace[
savedXText, {"[" -> "(", "]" -> ")",
"t" -> "m.lammda[i]*180/np.pi", "u" -> "m.phi[i]*180/np.pi"}];
Export["testStack.txt", savedXText2];
This will be used later on in a python program.
testStack.txt has three rows (however, in the future it could have more or less depending on the number of nodes I am working with). Unfortunately, the code doesn't do what I need.
I would like to know if there is a way to aknowledge the row in which one is by writing it in lammda and phi. i.e for the first row I would like to know if
"t" -> "m.lammda1[i]*180/np.pi"
and "u" -> "m.phi1[i]*180/np.pi
can be written and in a similar fashion,
"t" -> "m.lammda2[i]*180/np.pi"
and "u" -> "m.phi2[i]*180/np.pi
for the second row and so on.
I am certain that it can be done by using a for loop or a table where a variable takes the value of the row of savedText (the original before the StringReplace) and then use StringForm or toString in the StringReplace, but I cannot do it.
This is the first row of testStack.txt
-19.995904426195736*Sinc(0.04188790204786391*(0. + m.lammda[i]*180/np.pi))*Sinc(0.08975979010256552*(-65. + m.phi1[i]*180/np.pi)) - 37.58848602557134*Sinc(0.04188790204786391*(75. + m.lammda[i]*180/np.pi))*Sinc(0.08975979010256552*(-65. + m.phi1[i]*180/np.pi)) - 26.820905985723094*Sinc(0.04188790204786391*(0. + m.lammda[i]*180/np.pi))*Sinc(0.08975979010256552*(-30. + m.phi1[i]*180/np.pi)) - 15.904862946583352*Sinc(0.04188790204786391*(75. + m.lammda[i]*180/np.pi))*Sinc(0.08975979010256552*(-30. + m.phi1[i]*180/np.pi))