roy1989
Civil/Environmental
- Dec 8, 2015
- 4
I want to read the data extracted from the text file into Abaqus File for the simulation. Here is my code:
import os
os.chdir(r"dir")
for file in os.listdir("dir"):
if file.endswith('.txt'):
print os.path.join(r"dir", file)
with open(file) as f:
lines = f.readlines()
for line in lines[:-1]:
first, second = tuple(map(float, line.split()))
print '(%g, %g),' % (first, second),
first, second = tuple(map(float, lines[-1].split()))
pp = '(%g, %g)' % (first, second)
print pp
mdb.models['Model-1'].TabularAmplitude(data=(pp), name='NewAmplitude', smooth=
SOLVER_DEFAULT, timeSpan=STEP)
The error which comes up is "TypeError: data; found string, expecting tuple". Can anyone help in solving the issue?
import os
os.chdir(r"dir")
for file in os.listdir("dir"):
if file.endswith('.txt'):
print os.path.join(r"dir", file)
with open(file) as f:
lines = f.readlines()
for line in lines[:-1]:
first, second = tuple(map(float, line.split()))
print '(%g, %g),' % (first, second),
first, second = tuple(map(float, lines[-1].split()))
pp = '(%g, %g)' % (first, second)
print pp
mdb.models['Model-1'].TabularAmplitude(data=(pp), name='NewAmplitude', smooth=
SOLVER_DEFAULT, timeSpan=STEP)
The error which comes up is "TypeError: data; found string, expecting tuple". Can anyone help in solving the issue?