Skip to content

Instantly share code, notes, and snippets.

@QiangF
Forked from crmccreary/process_abaqus_rpt.py
Created June 15, 2016 13:15
Show Gist options
  • Save QiangF/592960571d583f0c9b81b1a7a02b001e to your computer and use it in GitHub Desktop.
Save QiangF/592960571d583f0c9b81b1a7a02b001e to your computer and use it in GitHub Desktop.
This python function attempts to convert the XYData report generated by Abaqus into something useful
def process_rpt(fname):
with open(fname, 'rb') as f:
lines = f.readlines()
lines_cleaned = []
for line in lines:
# Strip leading and trailing whitespace
line_cleaned = line.lstrip().rstrip()
# Ignore blank lines
if len(line_cleaned):
# Check if first element is a float
line_cleaned = line_cleaned.split()
try:
float(line_cleaned[0])
lines_cleaned.append(line_cleaned)
except:
pass
tmp = np.zeros((len(lines_cleaned),len(lines_cleaned[0])))
for i,line in enumerate(lines_cleaned):
tmp[i,:] = np.array(map(float, line))
return tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment