export-saved-reddit
export-saved-reddit copied to clipboard
added the str() type cast to the row to fix the following error:
Traceback (most recent call last): File ".\export_saved.py", line 244, in write_csv csvwriter.writerow(csv_fields) TypeError: a bytes-like object is required, not 'str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\export_saved.py", line 253, in write_csv
csvwriter.writerow(row)
File "H:\Programs\Python\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f61c' in position 168: character maps to
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\export_saved.py", line 329, in
Codecov Report
Merging #44 into master will not change coverage. The diff coverage is
0%
.
@@ Coverage Diff @@
## master #44 +/- ##
======================================
Coverage 94.9% 94.9%
======================================
Files 1 1
Lines 157 157
======================================
Hits 149 149
Misses 8 8
Impacted Files | Coverage Δ | |
---|---|---|
export_saved.py | 94.9% <0%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 64a37f6...24206e3. Read the comment docs.
When I ran the script, I got this error because it was trying to pass a list, in the exception. Adding the str() type cast fixed the issue, for me anyway. Without it, I got the error above after about 200 saved links.
can you post the error traceback?
Traceback (most recent call last): File ".\export_saved.py", line 244, in write_csv csvwriter.writerow(csv_fields) TypeError: a bytes-like object is required, not 'str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File ".\export_saved.py", line 253, in write_csv csvwriter.writerow(row) File "H:\Programs\Python\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f61c' in position 168: character maps to
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File ".\export_saved.py", line 329, in main() File ".\export_saved.py", line 323, in main save_saved(reddit) File ".\export_saved.py", line 287, in save_saved process(reddit, seq, "export-saved", "Reddit - Saved") File ".\export_saved.py", line 269, in process write_csv(csv_rows, file_name + ".csv") File ".\export_saved.py", line 255, in write_csv csvwriter.writerow(row.encode('utf-8', 'ignore')) AttributeError: 'list' object has no attribute 'encode'