I need to read binary format. My file has *.grd format for Surfer. I need to reed data header.
I used this code, but it's dosen't work.
import numpy as np
def read_grd(filename):
with open(filename) as infile:
ncols = int(infile.readline().split()[1])
nrows = int(infile.readline().split()[1])
xllcorner = float(infile.readline().split()[1])
yllcorner = float(infile.readline().split()[1])
cellsize = float(infile.readline().split()[1])
nodata_value = int(infile.readline().split()[1])
version = float(infile.readline().split()[1])
longitude = xllcorner + cellsize * np.arange(ncols)
latitude = yllcorner + cellsize * np.arange(nrows)
value = np.loadtxt(filename, skiprows=7)
return(longitude, latitude, value)
read_grd('filename.grd')
So, ehen I used this code I got a mistake: return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1486: character maps to