Last active
September 29, 2019 14:33
-
-
Save garystafford/aeb3ee92e3abf9393c3a2896894a8adf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from pyspark.sql import SparkSession | |
from pyspark.sql.types import StructType, StructField, StringType, IntegerType | |
spark = SparkSession \ | |
.builder \ | |
.getOrCreate() | |
sc = spark.sparkContext | |
bakery_schema = StructType([ | |
StructField('date', StringType(), True), | |
StructField('time', StringType(), True), | |
StructField('transaction', IntegerType(), True), | |
StructField('item', StringType(), True) | |
]) | |
df3 = spark.read \ | |
.format('csv') \ | |
.option('header', 'true') \ | |
.load('BreadBasket_DMS.csv', schema=bakery_schema) | |
df3.show(10) | |
df3.count() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment