我们尝试以下列方式读取excel文件:
收到一个错误声明:未能初始化fs.azure.account.key检测到的configurationInvalid配置值
注意:
发布于 2022-10-12 07:28:47
尝试这个访问您的ADLS
configs = {"fs.azure.account.auth.type": "OAuth",
"fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
"fs.azure.account.oauth2.client.id": f"{client_id}",
"fs.azure.account.oauth2.client.secret": f"{client_secret}",
"fs.azure.account.oauth2.client.endpoint": f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"}
def mount_adls(container_name2):
dbutils.fs.mount(
source = f"abfss://{container_name2}@{storage_account_name}.dfs.core.windows.net/",
mount_point = f"/mnt/{storage_account_name}/{container_name2}",
extra_configs = configs)
发布于 2022-10-11 11:13:57
您可以使用熊猫读取.xlsx文件,然后将其转换为触发数据格式。
from pyspark.sql import SparkSession
import pandas
spark = SparkSession.builder.appName("Test").getOrCreate()
pdf = pandas.read_excel('excelfile.xlsx', sheet_name='sheetname', inferSchema='true')
df = spark.createDataFrame(pdf)
df.show()
https://stackoverflow.com/questions/74031467
复制