Open source software supply chain lighting plan, waiting for you>>>
When Python reads a file, it appears_ When CSV. Error: line contains null byte
# -*- coding:utf-8 -*-
import csv
with open(r'E:\abc\web_test\userinfo.csv','rb') as f:
reader = csv.reader(f)
rows = [row for row in reader]
print rows
Error:
D:\Python27\python.exe E:/abc/loop_reader.py
Traceback (most recent call last):
File "E:/abc/web_test/loop_reader.py", line 7, in <module>
rows = [row for row in reader]
_csv.Error: line contains NULL byte
Process finished with exit code 1
The error prompt is:_ csv.Error: line contains NULL byte
CSV error, line contains empty bytes
Reason: it is usually because the extension is XLS or xlsx when saving, and changing it to a CSV file is usually a rename
Solution: save it as a. CSV file
Similar Posts:
- python csv error: line contains null byte [How to Solve]
- Call to undefined function socket_create()
- Python FAQ – error using openpyxl module: zipfile.BadZipFile : File is not a zip file
- [Solved] Unicode decode error in the background when the robot framework is running
- [Solved] An error occurred when paddlepaddle iterated data: typeerror: ‘function’ object is not iterative
- [Solved] The paramiko module failed to upload the file: paramiko.ssh_exception.SSHException: Channel closed.
- [Solved] UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x89 in position 0: invalid start byte
- [Solved] DOM parsing XML Error: Content is not allowed in prolog
- [Solved] Changing the selected file Error when uploading excel file. Net:: err_UPLOAD_FILE_CHANGED
- PIP install troubleshooting under Windows [How to Solve]