0

我需要编写一个程序来处理Python远程服务器文件夹中的所有excel文件。要在我的计算机上处​​理一个 excel 文件,我使用

from xlrd import open_workbook
book = open_workbook( filename)

然后处理book 但是,我不知道如何在远程服务器上获取 excel 文件进行处理。请帮帮我。如果可能,请告诉我如何获取远程服务器文件夹中的所有 excel 文件。非常感谢。

4

1 回答 1

0
import os

excelfiles = []

for cwd, folders, files in os.walk(starting_directory):  # For file in starting_directory
    for filename in files:
        path = os.path.join(cwd, filename)
        if os.path.splitext(path)[1].lower() == '.xls':  # If the file ends in '.xls'
            excelfiles.append(path)

for spreadsheet in excelfiles:
    process_spreadsheet(spreadsheet)
于 2013-01-08T02:05:15.630 回答