[英]Python how to Read last modified date of file from TeamSites
我正在使用Shuttle軟件包將Excel文件讀寫到TeamSites。以下是相同的代碼:
from shuttle import sharepoint, rfs
with rfs.open(TS, 'Reports/Weekly/Python_Datasets/fcs.csv','r') as remote_file:
fcs1=pd.read_csv(remote_file)
我如何從Teamsites讀取同一文件的最后修改日期和時間。
from shuttle import sharepoint, rfs
with rfs.open(TS, 'Reports/Weekly/Python_Datasets/fcs.csv','r') as remote_file:
fcs1=os.path.getmtime(remote_file)
TypeError: coercing to Unicode: need string or buffer, instance found
我在這里做錯了什么?
謝謝
您從rfs.open(xxx)
獲得了類似文件的對象,它不是getmtime
所需的字符串或緩沖區。
參見https://docs.python.org/3.6/library/os.path.html#os.path.getmtime 。
經過研究,我找到了我問題的答案。 希望它能幫助其他人:
Shuttle具有功能List,該功能將打印文件的所有元數據信息。下面是我使用的語法:
dt1=TS.list('Reports/Monitoring/Forecast/file.csv')
這是列表格式,將其轉換為json並讀取json
dt1=pd.read_json(json.dumps(dt1)).TimeLastModified
這給出了共享點/團隊站點上文件的最后時間戳。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.