Created
November 22, 2013 14:42
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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