- 数据生成逻辑
import java.io.{File, FileWriter}
import org.apache.spark.util.random
import scala.util.Random
object DealDataExample4_1 {
val random = new Random()
val arr = Array("北京","上海","广州","深圳","天津","重庆","南京")
/**
* 随机生成城市
* @return
*/
def city():String={
//随机获取城市
arr(random.nextInt(7))
}
/**
* 随机生成温度
* @return
*/
def temp():Double={
val tm:Double = (random.nextInt(999)+2000)*0.01
tm.formatted("%.2f").toDouble
}
def mouth():String={
val mth = (random.nextInt(11)+1).toString
mth.concat("月份")
}
def main(args: Array[String]): Unit