DanieleO
DanieleO

Reputation: 472

SparkR df read as one column

txt with 4 column divided by \t.

When I read it in this way:

A<-read.df(sqlContext,"/home/daniele/Tnt3.txt", "com.databricks.spark.csv")

SparkR read it all as one column

 a\tb\tc\td

How can I change the \t to , in sparkR?

(I know that I can change it manually like this sed -i 's/\t/,/g' file but is a little bit slowly)

Upvotes: 1

Views: 582

Answers (2)

xyzzy
xyzzy

Reputation: 329

a <- read.df(sqlContext, "/home/daniele/Tnt3.txt", "com.databricks.spark.csv", delimiter="\t")

Upvotes: 3

DanielVL
DanielVL

Reputation: 249

You should specify delimiter.

Im newer in R, but i think is something like this

A<-read.df(sqlContext,"/home/daniele/Tnt3.txt", "com.databricks.spark.csv").options("delimiter", "\t")

for more info, visit page of spark-csv:

https://github.com/databricks/spark-csv

Upvotes: 0

Related Questions