微信小程序上传 excel 文件到华为函数工作流处理 存到mysql
华为函数工作流接收的文件存在body里面 使用pandas 能读出 但是函数工作流 导入pandas库各版本都报错
用xlrd 读取body数据也报错
body里面数据 b64解码后 海需要处理吗?
您遇到的错误可能与您使用的 pandas 版本有关。请务必确保您使用的 Pandas 版本与华为函数工作流程中使用的 Python 版本兼容。
对于body中的数据,如果已经使用base64编码,则需要先使用b64decode函数对其进行解码,然后才能使用pandas或xlrd进行处理。以下是如何在 Python 中执行此操作的示例:
import base64
# Assuming that the data in the body is stored in a variable called "body_data"
decoded_data = base64.b64decode(body_data)
解码数据后,您应该可以使用 pandas 或 xlrd 读取 Excel 文件的内容。
import pandas as pd
# Read the Excel file using pandas
df = pd.read_excel(decoded_data)
import xlrd
# Read the Excel file using xlrd
workbook = xlrd.open_workbook(file_contents=decoded_data)
我希望这有帮助!如果您还有其他问题,请告诉我。