I want from a text file in format:
first line
column1;column2;column3
column1;column2;column3
last line
to convert it into DataFrame without the first and the last line I have skippet the first and the last line but then I become the rest text in one row and onw column How can I arrange the rows? I have also a schema for my DataFrame
var textFile = sc.textFile("*.txt")
val header = textFile.first()
val total = textFile.count()
var rows = textFile.zipWithIndex().filter(x => x._2 < total - 1).map(x => x._1).filter(x => x != header)
val schema = StructType(Array(
StructField("col1", IntegerType, true),
StructField("col2", StringType, true),
StructField("col3", StringType, true),
StructField("col4", StringType, true)
))