pythonpandasdat-protocol

how to change the data of an airfoil points.dat file from columns to rows


I am interested in developing an application that generates as output the points of an airfoil in rows, in which the row contains the airfoil data, in coordinates x1, y1 | x2, y2 | x3, y3 | From the website airfoilTools AirfoilData, I get the airfoil information in columns. The primary purpose is to generate a file containing a lot of airfoil points in rows Example


Solution

  • IIUC, you can use this oneline:

    '|'+'|'.join([' '.join([str(y) for y in x]) for x in pd.read_csv('https://m-selig.ae.illinois.edu/ads/coord/n0009sm.dat', delim_whitespace=True).iloc[:, :-1].values])
    

    Output:

    '|1.0 0.0|0.99572 0.00057|0.98296 0.00218|0.96194 0.00463|0.93301 0.0077|0.89668 0.01127|0.85355 0.01522|0.80438 0.01945|0.75 0.02384|0.69134 0.02823|0.62941 0.03247|0.56526 0.03638|0.5 0.03978|0.43474 0.04248|0.37059 0.04431|0.33928 0.04484|0.30866 0.04509|0.27886 0.04504|0.25 0.04466|0.22221 0.04397|0.19562 0.04295|0.17033 0.04161|0.14645 0.03994|0.12408 0.03795|0.10332 0.03564|0.08427 0.03305|0.06699 0.03023|0.05156 0.0272|0.03806 0.02395|0.02653 0.02039|0.01704 0.01646|0.00961 0.01214|0.00428 0.00767|0.00107 0.00349|0.0 0.0|0.00107 -0.00349|0.00428 -0.00767|0.00961 -0.01214|0.01704 -0.01646|0.02653 -0.02039|0.03806 -0.02395|0.05156 -0.0272|0.06699 -0.03023|0.08427 -0.03305|0.10332 -0.03564|0.12408 -0.03795|0.14645 -0.03994|0.17033 -0.04161|0.19562 -0.04295|0.22221 -0.04397|0.25 -0.04466|0.27886 -0.04504|0.30866 -0.04509|0.33928 -0.04484|0.37059 -0.04431|0.43474 -0.04248|0.5 -0.03978|0.56526 -0.03638|0.62941 -0.03247|0.69134 -0.02823|0.75 -0.02384|0.80438 -0.01945|0.85355 -0.01522|0.89668 -0.01127|0.93301 -0.0077|0.96194 -0.00463|0.98296 -0.00218|0.99572 -0.00057|1.0 0.0'