Python Forum
g Null Byte using DictReader
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
g Null Byte using DictReader
#1
I have the below code
stream = io.StringIO(csv_file.stream.read().decode('utf-8-sig'), newline=None) // error is here

reader = csv.DictReader(stream)

list_of_entity = []
line_no, prev_len = 1, 0,

for line in reader:
While executing the above code I got the below error. UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 252862: invalid start byte

Later to fix this I tried the below.
stream = io.StringIO(csv_file.stream.read().decode('unicode_escape'), newline=None)

reader = csv.DictReader(stream)

list_of_entity = []
line_no, prev_len = 1, 0,

for line in reader:// error is here
when i change decode as unicode_escape it thrown the error "_csv.Error: line contains NULL byte" at above highlighted comment line.

There is null byte present in csv, I want to ignore or replace it. can anyone help on this.
Reply


Messages In This Thread
g Null Byte using DictReader - by eshwinsukhdeve - May-15-2019, 05:08 AM
RE: g Null Byte using DictReader - by Larz60+ - May-15-2019, 05:46 AM
RE: g Null Byte using DictReader - by buran - May-15-2019, 06:26 AM
RE: g Null Byte using DictReader - by buran - May-15-2019, 07:07 AM
RE: g Null Byte using DictReader - by buran - May-15-2019, 07:15 AM
RE: g Null Byte using DictReader - by buran - May-15-2019, 07:53 AM
RE: g Null Byte using DictReader - by buran - May-15-2019, 08:17 AM
RE: g Null Byte using DictReader - by buran - May-15-2019, 08:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to express null value klatlap 3 859 Mar-25-2023, 10:40 AM
Last Post: klatlap
  value null when update in json file 3lnyn0 6 3,230 Dec-30-2021, 05:52 PM
Last Post: ndc85430
  'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte tienttt 12 11,523 Sep-18-2020, 10:10 PM
Last Post: tienttt
  Multiple conditions, one is null moralear27 1 2,197 Sep-13-2020, 06:11 AM
Last Post: scidam
  I didnt get the NULL values salwa17 0 1,582 Jul-10-2020, 02:54 PM
Last Post: salwa17
  Find only the rows containing null values Bhavika 2 2,437 Jun-10-2020, 01:25 PM
Last Post: Bhavika
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 8 31,657 Feb-08-2020, 06:58 PM
Last Post: karkas
  Array/Jarray problem contains null value? Maverick0013 1 3,960 Aug-10-2018, 12:56 PM
Last Post: Windspar
  4 byte hex byte swap from binary file medievil 7 22,079 May-08-2018, 08:16 AM
Last Post: killerrex
  csv.reader vs csv.dictReader mepyyeti 3 20,859 Mar-20-2018, 08:31 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020