Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
.DS_Store
*.pyc
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/pyspark-examples.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added aws-jars-needed-for-s3/aws-java-sdk-1.12.183.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added aws-jars-needed-for-s3/hadoop-aws-2.7.4.jar
Binary file not shown.
Empty file added kapil-practice/CreateSpark.py
Empty file.
25 changes: 25 additions & 0 deletions kapil-practice/S3Df.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pyspark.sql.session import SparkSession
from pyspark.sql.functions import *
from pyspark.sql.window import *
from pyspark.sql.types import *

spark = SparkSession.builder.\
master("local").\
appName("prac").\
getOrCreate()

sc = spark.sparkContext
sc._jsc.hadoopConfiguration().set("com.amazonaws.services.s3.enableV4", "true")
sc._jsc.hadoopConfiguration().set("fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")
sc._jsc.hadoopConfiguration().set("fs.s3a.aws.credentials.provider", "com.amazonaws.auth.InstanceProfileCredentialsProvider,com.amazonaws.auth.DefaultAWSCredentialsProviderChain")
sc._jsc.hadoopConfiguration().set("fs.AbstractFileSystem.s3a.impl", "org.apache.hadoop.fs.s3a.S3A")
sc._jsc.hadoopConfiguration().set("fs.s3a.endpoint", "s3.us-east-1.amazonaws.com")

sc._jsc.hadoopConfiguration().set('fs.s3a.access.key', 'A')
sc._jsc.hadoopConfiguration().set('fs.s3a.secret.key', 'VracelDcLui')
sc._jsc.hadoopConfiguration().set("fs.s3a.endpoint", "s3.amazonaws.com")

df = spark.read.option("inferSchema","true").option("header","true").csv("s3a://ind-north-up-agra-kapil-test-1/datasets/input-ds/movies/")
df.show()

spark.stop()
Empty file added kapil-practice/__init__.py
Empty file.
Binary file not shown.
15 changes: 15 additions & 0 deletions kapil-practice/kp-convert-column-python-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyspark.sql.functions import *
from pyspark.sql import SparkSession

spark = SparkSession.builder.master("local[1]") \
.appName('SparkByExamples.com') \
.getOrCreate()

nasa_df = spark.read.json("G:\\datasets\\input-datasets\\json-datasets\\nasa-singleline-zipcodes.json")
nasa_df.printSchema()

nasa_df.show()

# all_cities = nasa_df.select("City").distinct().rdd.map(lambda x: x.City).collect()
# print(all_cities)
spark.stop()
Empty file added spark-by-examples/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.appName("SparkByExamples.com") \
.getOrCreate()

filePath="resources/small_zipcode.csv"
filePath= "../resources/small_zipcode.csv"
df = spark.read.options(header='true', inferSchema='true') \
.csv(filePath)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.appName("SparkByExamples.com") \
.getOrCreate()

filePath="resources/small_zipcode.csv"
filePath= "../resources/small_zipcode.csv"
df = spark.read.options(header='true', inferSchema='true') \
.csv(filePath)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.