Python Forum

Full Version: g Null Byte using DictReader
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This below error is fixed.
utf-8' codec can't decode byte 0xa0 in position 252862: invalid start byte

but currently getting error.
_csv.Error: line contains NULL byte
on line "for line in reader:"

the below error is fixed.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 252862: invalid start byte

but getting the below error now.
_csv.Error: line contains NULL byte
at line "for line in reader:"
can you post minimal example that reproduce your problem as well as the input file you work with
Hi Buran,
this code is a part of my project.
and the csv file I am reading it from rest api which contains NULL Byte.
def getCSV(csv_file):
    
    stream = io.StringIO(csv_file.stream.read().decode('utf-8'),  newline=None)
    reader = csv.DictReader(stream)

    list_of_entity = []
    line_no, prev_len = 1, 0,
    for line in reader:
.......
cant share the csv as it has confidential data.

thank you for understanding.
at the moment I cannot suggest anything helpful. maybe someone else could help more
Pages: 1 2