How can we export results to text file and then combine all files into one file
Erik Kostson
Member, Moderator, Employee Posts: 276
✭✭✭✭
How can we export results to a text file and then combine all files into one file automatically?
Tagged:
0
Answers
-
Similar question has been asked in the Ansys learning forum, and the answer to this is:
global files files=[] anls=ExtAPI.DataModel.Project.Model.Analyses maxnls=len(anls) for j in range(0,maxnls): res=anls[j].Solution.Children maxres=len(res) for i in range(1,maxres): res[i].ExportToTextFile(bool,'''D:\'''+str(res[i].Name)+'''_nls_'''+str(j)+'''_'''+str(i)+'''.txt''') files.append('''D:\'''+str(res[i].Name)+'''_nls_'''+str(j)+'''_'''+str(i)+'''.txt''') with open("D:\output_file.txt", "w") as outfile: for filename in files: with open(filename) as infile: contents = infile.read() outfile.write(contents)
2