使用Python3 Sharepy从共享的0365商业共享点下载Excel文件会导致文件损坏

时间:2019-06-07 12:06:44

标签: python-3.x sharepoint-online

类似于上一个未得到完全回答的问题,here,我正尝试使用Python3和Sharepy下载Excel文件,使用熊猫对其进行操作,然后将其重新上传回sharepoint。

问题可能是,我不知道真正的excel文件存储在哪里,我只有一个参考链接,该链接可以共享给其他具有访问权限的人。下载该链接是指向Excel Online的html,而不是我想要的Excel文件。有提示吗?

import sharepy
from sharepy import connect
from sharepy import SharePointSession

server='https://mycompany365.sharepoint.com'
user='first.m.last@mycompany.com'
password='1234Password1234'

# Copy/Paste file link from sharepoint below. #<--- partially works
site = "https://mycompany.sharepoint.com/:x:/r/sites/Sales/Shared%20Documents/General/My_File.xlsx?d=wb182f80code74bd586b225codebeb1c&csf=1&e=CodeeT"

s = sharepy.connect(server,user,password)

#  Download file to same folder as python script, save as My_File.xlsx.
r = s.getfile(site,\
 filename = 'My_File.xlsx')

print("Script Complete")

我的网站=导致html指向正确的在线文件,而不是真正的Excel文件。如何找到真实文件在哪里?

1 个答案:

答案 0 :(得分:0)

经过一番蛮力之后,我发现删除“共享链接”末尾的随机代码会打开原始文件:

list_info = ListInfoService::ListInfo.new(
  value, # Note that this line is `ids` under ListInfoService::ListInfo argument and cant be array.
  params[:some_params], 
  params[:another_params]).movies 

render json: list_info