I have the following code:
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'
However, it runs very slow (minutes) in the python interpeter of an external program (I have to run the script here because I need to access a database of results produced by this program). How can I optimize it?
EDIT:
I close the inputFile at the end of the code: inputFile.close()
....?