trying to read a csv file into a dataframe simple code
df = spark.read.csv("1.csv")
i got
df.printSchema()
root
|-- _c0: string (nullable = true)
also i try this
db = spark.read.csv("1.csv", header=True, inferSchema= "True")
db.printSchema()
root
|-- id | date | cases | country | deaths | cities | per_cap |
Thanks in advance for your help
apparently, your line seperator is a pipe |
.
try:
db = spark.read.csv("1.csv", sep='|', header=True, inferSchema= "True")
for col in db.columns:
db = db.withColumnRenamed(col, col.strip())
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments