index a dataframe from a csv file based on the file's original order (not based on any specific column, based on the entire row) using spark
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 12:03 PM
how to guarantee the index is always following the file's original order no matter what. Currently, I'm using val df = spark.read.options(Map("header"-> "true", "inferSchema" -> "true")).csv("filePath").withColumn("index", monotonically_increasing_id()) .
Thanks!
Labels:
- Labels:
-
Index
-
Specific Column