1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
【以下的回答经过翻译处理】 如果您使用Glue爬取文件并将其添加到Glue目录中,您可以设置此表属性:
skip.header.line.count=1
我在控制台中手动设置了该属性,可以忽略了标题行,在Athena中进行了查询。您也可以通过API或在CloudFormation模板中设置表属性。
如果您使用Glue Spark库查询Catalog中的表,也可以这样做:
import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
glueContext = GlueContext(SparkContext.getOrCreate())
df = glueContext.create_dynamic_frame.from_catalog(
database = "default",
table_name = "headertest_headertest")
df.printSchema()
df.toDF().show()
如果您直接将CSV读入Dynamic Dataframe,您可以使用withHeader连接选项:
dfs3 = glueContext.create_dynamic_frame_from_options(connection_type = "s3", connection_options = {"paths": ["s3://rd-mb3/headertest/"]}, format="csv", format_options = {"withHeader": True})
dfs3.toDF().show()
Contenus pertinents
- demandé il y a 7 mois
- demandé il y a un an
- demandé il y a 2 mois
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans