---
# System prepended metadata

title: 744 HW1

---

# 744 HW1

    
    
    
```=python
from pyspark.sql import SparkSession

import sys

if __name__=="__main__":
	argv = sys.argv
	ss = SparkSession.builder.appName("q2").config("Spark.sql.sources.default", "json").master(argv[1]).getOrCreate()

	ds = ss.read.option("inferSchema", "true").csv(argv[2]).toDF("battery_level","c02_level","cca2","cca3","cn","device_id","device_name","humidity","ip","latitude","lcd","longitude","scale","temp","timestamp")

	ds.sort("cca2", "timestamp").write.format("csv").save(argv[3])


```