Skip to content

Conversation

@HadManySons
Copy link

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'

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 <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\export_saved.py", line 329, in <module>
    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'
@codecov-io
Copy link

Codecov Report

Merging #44 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@          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%> (ø) ⬆️

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.

csvwriter.writerow(row)
except UnicodeEncodeError:
csvwriter.writerow(row.encode('utf-8', 'ignore'))
csvwriter.writerow(str(row).encode('utf-8', 'ignore'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

row here is a list, so str type cast it will create error on the csv writer.

@HadManySons
Copy link
Author

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.

@rachmadaniHaryono
Copy link
Collaborator

can you post the error traceback?

@HadManySons
Copy link
Author

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants