Skip to content

Commit

Permalink
Merge pull request #1054 from burnash/feature/encode_csv_string_to_un…
Browse files Browse the repository at this point in the history
…icode

Encode string to utf-8 when importing CSV content
  • Loading branch information
lavigne958 committed May 31, 2022
2 parents a666fa3 + 1f3fe2d commit bb4e9f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gspread/client.py
Expand Up @@ -387,6 +387,10 @@ def import_csv(self, file_id, data):
replaces the contents of the first worksheet.
"""
# Make sure we send utf-8
if type(data) is str:
data = data.encode("utf-8")

headers = {"Content-Type": "text/csv"}
url = "{}/{}".format(DRIVE_FILES_UPLOAD_API_V2_URL, file_id)

Expand Down

0 comments on commit bb4e9f1

Please sign in to comment.