Created
October 18, 2019 17:37
-
-
Save viniroger/097de619aa7887f4430057c9bea52a04 to your computer and use it in GitHub Desktop.
Save dataframe at file with same width columns
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
import pandas as pd | |
df1 = pd.read_csv('input.csv', delimiter=';', header=None) | |
# Save into fixed columns file | |
import numpy as np | |
with open('output.dat', 'w') as ofile: | |
fmt = '%5d %4d %4d %4d %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f' | |
np.savetxt(ofile, df1.values, fmt=fmt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment