次のコードがあります。
inputFile = open('C:/Abaqus_JOBS' + JobDir + '/' + JobName + '-3_4.inp', 'r')
for line in inputFile:
fileData.append([x.strip() for x in line.split(',')])
fel=0
for row,data in enumerate(fileData):
if data[0]=='*Node':
row_nodes = row #number of the row when data='*Node'
if data[0]=='*Element' and fel==0:
row_elements2 = row
fel=1
for row,data in enumerate(fileData[row_nodes + 1:row_elements2]):
nodes.append(data) #data between '*Nodes' and '*Element'
ただし、外部プログラムの python インターピーターでは非常に遅く (数分) 実行されます (このプログラムによって生成された結果のデータベースにアクセスする必要があるため、ここでスクリプトを実行する必要があります)。どうすれば最適化できますか?
編集:inputFile
コードの最後で閉じます:inputFile.close()