com.aamend.spark.gdelt.reference.CountryCodes.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spark-gdelt Show documentation
Show all versions of spark-gdelt Show documentation
Working with GDELT from Spark environment
The newest version!
package com.aamend.spark.gdelt.reference
import com.aamend.spark.gdelt.CountryCode
import org.apache.spark.sql.{Dataset, SparkSession}
import scala.io.Source
object CountryCodes {
def load(spark: SparkSession): Dataset[CountryCode] = {
import spark.implicits._
Source.fromInputStream(this.getClass.getResourceAsStream("/countryInfo.txt")).getLines().toSeq.drop(1).map(line => {
val tokens = line.split("\t")
CountryCode(
iso = tokens(0),
iso3 = tokens(1),
isoNumeric = tokens(2),
fips = tokens(3),
country = tokens(4).toLowerCase()
)
}).toDS()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy