jakevdp / PythonDataScienceHandbook

Python Data Science Handbook: full text in Jupyter Notebooks
http://jakevdp.github.io/PythonDataScienceHandbook
MIT License
42.89k stars 17.85k forks source link

how to read asc file in python #325

Open haritha1022 opened 2 years ago

haritha1022 commented 2 years ago

hello sir I have couple of asc files in each file there is a some meteorological data (temperature,humidity)

previous, I worked with netcdf ,grib data now my data extension is asc format plain text how can i read this .asc format file

UditSharma9999 commented 2 years ago

You can simply load this type of file using numpy. EX: import numpy as np ascii_grid = np.loadtxt("filename.asc")

rajtilakjee commented 1 year ago

@haritha1022: .asc files are simple text files with 6 line headers. These lines contains the geographic information. You can use the loadtxt function in numpy, however, you need to skip the first 6 lines. Here's an example:

import numpy as np
ascii_grid = np.loadtxt("bio_1.asc", skiprows=6)