How to read multiline CSV file in Pyspark

我们两清 提交于 2021-02-04 08:26:12

问题


I'm using this tweets dataset with Pyspark in order to process it and get some trends according to the tweet's location. But I'm having a problem when I try to create the dataframe. I'm using spark.read.options(header="True").csv("hashtag_donaldtrump.csv") to create the dataframe, but if I look at the tweets column, this is the result I get:

Do you know how can I clean the CSV file so it can be processed by Spark? Thank you in advance!


回答1:


It looks like a multiline csv. Try doing

df = spark.read.csv("hashtag_donaldtrump.csv", header=True, multiLine=True)


来源:https://stackoverflow.com/questions/65723811/how-to-read-multiline-csv-file-in-pyspark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!