0
我正在使用databricks spark-csv模块以sqlContext的形式读取csv文件。我按照下面的示例所示自定义了我的模式。但是,我注意到在我的数据中,第三列是汽车的模型,其中的字符串在它前面总是有一个共同的字符串“model:”。有没有办法修剪掉常用字符串?当将csv读入火花sql数据框时删除列的常见字符串
from pyspark.sql import SQLContext
from pyspark.sql.types import *
sqlContext = SQLContext(sc)
customSchema = StructType([ \
StructField("year", IntegerType(), True), \
StructField("make", StringType(), True), \
StructField("model", StringType(), True), \
StructField("comment", StringType(), True), \
StructField("blank", StringType(), True)])
df = sqlContext.read \
.format('com.databricks.spark.csv') \
.options(header='true') \
.load('cars.csv', schema = customSchema)
你能否至少提供你试图阅读的CSV的样本? – eliasah