Skip to content

Instantly share code, notes, and snippets.

View corneliouzbett's full-sized avatar
:octocat:
Compiling dreams and ideas...

Kipchumba Bett corneliouzbett

:octocat:
Compiling dreams and ideas...
View GitHub Profile
@corneliouzbett
corneliouzbett / SparkSession.py
Created March 16, 2019 19:07
Creatng spark session in python
spark = SparkSession.builder\
.appName("Python Spark SQL basic example")\
.config("spark.some.config.option", "")
.getOrCreate()
from pyspark import SparkContext, SparkConf
if __name__ == "__main__":
conf = SparkConf().setAppName("take").setMaster("local[*]")
sc = SparkContext(conf = conf)
inputWords = ["spark", "hadoop", "spark", "hive", "pig", "cassandra", "hadoop"]
wordRdd = sc.parallelize(inputWords)
words = wordRdd.take(3)
@corneliouzbett
corneliouzbett / wordCount.py
Created March 15, 2019 14:00
It is a simple python code using apache spark to count words in text file
from pyspark import SparkContext, SparkConf
def display_words(words):
for w, we in words.items():
print("{} : {}".format(w, we))
if __name__ == "__main__":
conf = SparkConf().setAppName("word count").setMaster("local[2]")
sc = SparkContext(conf = conf)
@dnetix
dnetix / JavaRestClientTest.java
Last active September 16, 2022 09:30
Simple Java Rest Client posting JSON to a server
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;