Ich bin ein Newbiee zu Funken und habe Probleme beim Filtern einer Karte. Ich versuche, den Header aus der CSV-Datei zu entfernen und versuchen, bestimmte Datensätze auszulesen. aber aus irgendeinem Grund ist meine Filterbedingung nicht funktionierend.Spark Filter-Funktion mit Karte
val dataWithHeader = sc.textFile("/user/skv/airlines.csv")
val headerAndRows = dataWithHeader.map(x => x.split(",").map(_.trim)
val Header = headerAndRows.first
val data = headerAndRows.filter(_(0) != Header(0))
val maps = data.map(x => Header.zip(x).toMap)
//result looks like //res0:
// Array[scala.collection.immutable.Map[String,String]] =
// Array(Map(Code -> "19031", Description -> "Mackey International Inc.: MAC"),
// Map(Code -> "19032", Description -> "Munz Northern Airlines Inc.: XY"),
//now when i am trying to filter the map with the below condition the filter is not working ?
val result = maps.filter(x => x("Code") != "19031")
airlines.csv sieht aus wie
Code,Description
"19031","Mackey International Inc.: MAC"
"19032","Munz Northern Airlines Inc.: XY"
"19033","Cochise Airlines Inc.: COC"
"19034","Golden Gate Airlines Inc.: GSA"
"19035","Aeromech Inc.: RZZ"
"19036","Golden West Airlines Co.: GLW"
"19037","Puerto Rico Intl Airlines: PRN"
"19038","Air America Inc.: STZ"
"19039","Swift Aire Lines Inc.: SWT"
Dank Raphael ... ich benutze die die doub herauszunehmen ersetzen le quittes .. –