Python code for importing data from .txt file into ABAQUS
Python code for importing data from .txt file into ABAQUS
(OP)
I am trying to write a python script for a parametric study in ABAQUS. Part of this involves importing data from other .txt files into the amplitudes of my loads (the tabular amplitude in ABAQUS). How do I write this in my python code? In other words, how do I write a python code that imports data from a .txt file into the tabualr amplitude in ABAQUS? IS there a simple commad for this?
The amplitude will change for different types of simulations I run (i.e., the data in the .txt file that I import the data from will change slightly for different scenarios). Therefore, it is important that the python code is able to import this data into the tabular amplitude in ABAQUS, because manually copying the data is not an option.
Thanks
The amplitude will change for different types of simulations I run (i.e., the data in the .txt file that I import the data from will change slightly for different scenarios). Therefore, it is important that the python code is able to import this data into the tabular amplitude in ABAQUS, because manually copying the data is not an option.
Thanks





RE: Python code for importing data from .txt file into ABAQUS
you can do
f = open('workfile', 'w')
values=f.read() # read the complete file
values=f.readline() #read one line, loop over it to get them all
Then you get a string, probably you will need to do a split(',') or '\t' to get a list of values, still in string format but a float(x) can fix that.
Then, you reorder your values until you have the needed sequence of pairs of Floats specifying time/frequency and amplitude pairs to input into the TabularAmplitude(...).