Suggestion on exporting dfs2 to csv #356
-
I was hoping to get a suggestion on how i might be able to export *.dfs2 files into .csv,.txt type files. my aim is to export all the values as they are in a grid format into any ascii format. anyone with a suggestion? so far i managed to export x,y,z values in to a csv with all the zero values as null. I have a feeling there's a better way of doing what I wish to do. thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It can certainly be done, but .txt is not a well defined format. If you only need the values from a single item, and a single timestep and no info about time, geography, just the actual values you can use NumPy.savetxt. import numpy as np
import mikeio
ds = mikeio.read("../tests/testdata/gebco_sound.dfs2", time=0)
X = ds.Elevation.to_numpy()
Xud = np.flipud(X)
np.savetxt("elevation.csv",Xud, fmt="%5.2f", delimiter=",") |
Beta Was this translation helpful? Give feedback.
It can certainly be done, but .txt is not a well defined format.
If you only need the values from a single item, and a single timestep and no info about time, geography, just the actual values you can use NumPy.savetxt.