line contains NUL error in reading a .dat file

154 Views Asked by At

I want to read a dat file in python but I received the NUL error :

`from astropy.io import ascii`
ascii.read('fx=0.1_RHS=0.5_fa=0.5_x_lightcone_dtb_6minres.dat')

Error: line contains NUL

how can I solve this issue?

I've tried to read this file with csv.reader() through the following code. finally I could open the file but I suppose it's not an appropriate choice:

import csv

with open('fx=0.1_RHS=0.5_fa=0.5_x_lightcone_dtb_6minres.dat', newline='') as csv_file:
    reader = csv.reader(csv_file)
    while True:
        try:
            row = next(reader)
            print(row)
        except csv.Error:
            continue
        except StopIteration:
            break

these are some lines of the result which looks wrong: result

0

There are 0 best solutions below