Skip to content

Instantly share code, notes, and snippets.

@crmccreary
Created November 22, 2013 14:42
Show Gist options
  • Save crmccreary/7600935 to your computer and use it in GitHub Desktop.
Save crmccreary/7600935 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