pd.to_ In the case of CSV,
df3.to_csv('E:\\data\\xxxx.csv',index=False,header= 0,sep='|', encoding="utf-8", quoting=csv.QUOTE_NONE)
Error: need to escape, but no escape set
Reason: this problem may be because the description contains’ | ‘,’ | ‘is also a separator, and the CSV tries to escape it, but it can’t, because there is no separator csv.escapechars set up
Solution:
provide an escape char when quoting is quote_ When none, specify a character so that it is not restricted by the separator for escape.
df3.to_csv('E:\\data\\xxxx.csv',index=False,header= 0,sep='|', encoding="utf-8", quoting=csv.QUOTE_NONE,escapechar='|')
Reference:
https://stackoverflow.com/questions/32107790/writing-to-csv-getting-error-need-to-escape-for-a-blank-string
Read More:
- Python: How to handles HTML escape characters
- How to Solve jupyter notebook Read CSV files Error
- [Solved] ParserError: NULL byte detected. This byte cannot be processed in Python‘s native csv library
- Pandas read_csv pandas.errors.ParserError: Error tokenizing data
- Python: How to Set Line breaks and tabs for Strings
- How to Solve RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu
- Django CSV file Error: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb5 in position 0: invalid start
- [Solved] Python matplotlib Error: RuntimeError: In set_size: Could not set the fontsize…
- Python Error: _csv.Error sequence expected
- Pandas Read csv Error tokenizing data. C error: Expected 18 fields in line 173315, saw 20
- [Solved] ERROR: URL ‘s3://‘ is supported but requires these missing dependencies: [‘s3fs‘]. To install dvc wi
- Tensor for argument #2 ‘mat1‘ is on CPU, but expected it to be on GPU (while checking arguments for
- To solve the problem that the loss of verification set of resnet50 pre-training model remains unchanged
- [Solved] CUDA unknown error – this may be due to an incorrectly set up environment
- [Solved] import pyzed No Error, but import pyzed.sl report an Error (zed-pythonAPI Installing)
- RuntimeError: stack expects each tensor to be equal size, but got [x] at entry 0 and [x] at entry 1
- [Python] Right-click Selenium to Save the picture error: attributeerror: solution to module ‘pyscreen’ has no attribute ‘locationonwindow’
- Pychar can’t connect to Python console, but it can run. Py file, and Anaconda’s command line can run Python command
- How to Solve Python AttributeError: ‘dict’ object has no attribute ‘item’
- How to Solve Python AttributeError: ‘module’ object has no attribute ‘xxx’