I have a text file, its content is(for example):
388, 399, 100
*Nset, nset=All, internal, generate
1, 48, 1
*Elset, elset=All, internal, generate
1, 35, 1
** Section:solidplane
*Solid Section, elset=All, material="rigid body"
*End Instance
Now I want use Mathematica read the above content and modify it; for example,
(1) I want the number "48 (3rd line)" to change to number"388 (1st line)",
(2) I want the word "All (4th line)" to change to word "Whole",
How can I realize it?
So the output is:
388, 399, 100
*Nset, nset=All, internal, generate
1, 388, 1
*Elset, elset=Whole, internal, generate
1, 35, 1
** Section:solidplane
*Solid Section, elset=All, material="rigid body"
*End Instance
I have used the function "ReadList" but failed... Hope someone can help me
Import
andStringReplace
. $\endgroup$Import[file,{"Text","Lines"}]
. Then you need to cook up the appropriate string operations to make the desired changes. $\endgroup$