×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Python code for importing data from .txt file into ABAQUS

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

RE: Python code for importing data from .txt file into ABAQUS

Depends on the formatting of your .txt files.
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(...).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources