I am thinking of using Python requests module to PUT the csv file stored in AWS S3 (the file contains Japanese and needs to be converted from utf8 to Shift_jis).
Please let me know what kind of code I should write for this process.
import requests
import pandas aspd
# Retrieve csv file from S3
url="https://s3.amazonaws.com/your-bucket-name/your-file.csv"
r=requests.get(url)
# Convert to Shift_jis
df=pd.read_csv(r.content, encoding='utf-8')
df.to_csv("your-file.csv", index=False, encoding='shift_jis')
# PUT to SharePoint site
url="https://your-tenant.sharepoint.com/sites/your-site/_api/web/lists(guid'your-list-guid')/items(your-item-id)/AttachmentFiles/add(FileName='your-file.csv')"
headers = {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/octet-stream",
"Authorization": "Bearer" + access_token
}
with open("your-file.csv", "rb") as f:
© 2024 OneMinuteCode. All rights reserved.