简体   繁体   中英

How to skip footer/trailer record while loading csv file to hive table

The file is CSV with comma delimited.

Framework for ingesting CSV file is present. Header from the same file is skipped by:

Df.Option(“header”, “true”)

But trailer record in the same spark package, I am unable to skip it same logic.

Please help with this data ingestion.

Please check this reply:

spark how to remove last line in a csv file

A copy from the same reply:

val total = df.count();
val withoutFooter = df.zipWithIndex()
                        .filter(x => x._2 < total - 3)
                        .map (x => x._1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM