【发布时间】:2020-08-10 01:01:10
【问题描述】:
我有以下格式错误的 txt 文件:
id;text;contact_id
1;Reason contact\
\
The client was not satisfied about the quality of the product\
\
;c_102932131
我正在尝试使用 pyspark 加载文件:
df = sc.read\
.option("delimiter", ";")\
.option("header", "true")\
.option("inferSchema", "true")\
.option("multiLine", "true")\
.option("wholeFile", "true")\
.csv(os.path.join(appconfig.configs[appconfig.ENV]["ROOT_DIR"], "data", "input", file_name))
但列文本被截断,因为数据框是:
id|text|contact_id
1|Reason contact|null
null|null|c_102932131
所以我失去了所有其他的行。目标是以这种方式正确读取文件:
id|text|contact_id
1|Reason contact The client was satisfied not about the quality of the product|c_102932131
我该怎么做? 谢谢
【问题讨论】:
标签: csv dataframe apache-spark pyspark etl