{"id":8915,"date":"2026-09-21T05:41:44","date_gmt":"2026-09-21T05:41:44","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=8915"},"modified":"2026-09-22T16:22:11","modified_gmt":"2026-09-22T16:22:11","slug":"working-with-dataproc","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/","title":{"rendered":"Working with Dataproc"},"content":{"rendered":"\r\n<h1>Working With Dataproc: Four Spark Examples Over SSH<\/h1>\r\n<p>This runs four small Spark jobs directly on a Dataproc cluster&#8217;s master node over SSH, each a bit more involved than the last, counting movie ratings, totaling customer spending, finding the single most popular movie, then finding the top ten with their actual names attached. It complements the Submitting a Spark Job Through the Dataproc Console guide in this series, which shows the same kind of job submitted through the console interface instead of run directly on the cluster.<\/p>\r\n<p>This assumes a Dataproc cluster is already running. This walks through connecting to it, confirming Spark and Hive are available, then working through all four examples in order, since each introduces one new idea on top of the last.<\/p>\r\n<h2>Complete Process of Working With Dataproc<\/h2>\r\n<h3>Step 1: Connect to Your Cluster<\/h3>\r\n<p>Open the console, then<\/p>\r\n\r\n\r\n\r\n<p>Open Menu &gt; <a href=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc-cluster-creation\/\" target=\"_blank\" rel=\"noreferrer noopener\" data-type=\"URL\" data-id=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc-cluster-creation\/\">Dataproc<\/a> &gt; Clusters<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"339\" class=\"wp-image-8916\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png 456w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281-300x223.png 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Click your cluster.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"154\" class=\"wp-image-8917\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-282.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-282.png 502w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-282-300x92.png 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Click VM Instances.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"88\" class=\"wp-image-8918\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-283.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-283.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-283-300x42.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Click SSH next to the master node.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"572\" height=\"162\" class=\"wp-image-8919\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-284.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-284.png 572w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-284-300x85.png 300w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/figure>\r\n\r\n\r\n\r\n<h3>Step 2: Confirm Spark and Hive Are Available<\/h3>\r\n<p>pyspark<\/p>\r\n<p>This opens the PySpark shell if it is installed. Exit with control + d.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"214\" class=\"wp-image-8920\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-285.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-285.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-285-300x102.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Confirms Hive is available the same way. Exit with control d.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"61\" class=\"wp-image-8921\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-286.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-286.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-286-300x29.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>python -V<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"395\" height=\"66\" class=\"wp-image-8922\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-287.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-287.png 395w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-287-300x50.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>spark-shell<\/p>\r\n<p>Opens the Spark shell. Exit with control d.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"291\" class=\"wp-image-8923\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-288.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-288.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-288-300x139.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2>Example One: Counting Ratings<\/h2>\r\n<p>pwd<br \/>mkdir ratingscounter<br \/>cd ratingscounter<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"499\" height=\"106\" class=\"wp-image-8924\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-289.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-289.png 499w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-289-300x64.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>wget https:\/\/s3.amazonaws.com\/sankethadoop\/u.data<br \/>ls<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"196\" class=\"wp-image-8925\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-290.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-290.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-290-300x94.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>nano u.data<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"573\" height=\"70\" class=\"wp-image-8926\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-291.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-291.png 573w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-291-300x37.png 300w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The file&#8217;s contents are shown. Exit with control x.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"336\" height=\"200\" class=\"wp-image-8927\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-292.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-292.png 336w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-292-300x179.png 300w\" sizes=\"auto, (max-width: 336px) 100vw, 336px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>nano ratingscounter.py<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"49\" class=\"wp-image-8928\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-293.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-293.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-293-300x23.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Paste in the following, which counts how many ratings fall into each score:<\/p>\r\n<p>from pyspark import SparkConf, SparkContext<br \/>import collections<br \/><br \/>conf = SparkConf().setMaster(&#8220;local&#8221;).setAppName(&#8220;Ratings&#8221;)<br \/>sc = SparkContext(conf = conf)<br \/><br \/>lines = sc.textFile(&#8220;sparkdata\/u.data&#8221;)<br \/>ratings = lines.map(lambda x: x.split()[2])<br \/>result = ratings.countByValue()<br \/><br \/>sortedResults = collections.OrderedDict(sorted(result.items()))<br \/>for key, value in sortedResults.items():<br \/>\u00a0\u00a0\u00a0\u00a0print(&#8220;%s %i&#8221; % (key, value))<\/p>\r\n<p>If you rename the directory or file, update the path inside the script to match. Save and exit with control x, then y, then enter.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"286\" class=\"wp-image-8929\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-294.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-294.png 620w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-294-300x138.png 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Create Schema structure<\/p>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop fs -mkdir \/user\/&lt;userid&gt;\/sparkdata\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To create directory named sparkdata<\/p>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop fs -put u.data sparkdata\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To copy u.data file into sparkdata<\/p>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop fs -ls sparkdata\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0# to check the file is saved or not<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"99\" class=\"wp-image-8930\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-295.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-295.png 721w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-295-300x41.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>spark-submit ratingscounter.py<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"216\" class=\"wp-image-8932\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-297.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-297.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-297-300x103.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2>Example Two: Total Spend by Customer<\/h2>\r\n<p>cd<br \/>mkdir totalspendbycustomer<br \/>cd totalspendbycustomer<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"559\" height=\"89\" class=\"wp-image-8933\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-298.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-298.png 559w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-298-300x48.png 300w\" sizes=\"auto, (max-width: 559px) 100vw, 559px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>wget https:\/\/s3.amazonaws.com\/sankethadoop\/customer-orders.csv<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"692\" height=\"206\" class=\"wp-image-8934\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-299.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-299.png 692w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-299-300x89.png 300w\" sizes=\"auto, (max-width: 692px) 100vw, 692px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>ls<br \/>nano customer-orders.csv<\/p>\r\n<p>Confirm the file&#8217;s contents, then exit with control x.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"62\" class=\"wp-image-8935\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-300.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-300.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-300-300x30.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Opens the file.<\/p>\r\n\r\n\r\n\r\n<p>To exit press ctrl +x<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"206\" height=\"193\" class=\"wp-image-8936\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-301.png\" alt=\"\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 pwd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Displays the path<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"544\" height=\"68\" class=\"wp-image-8937\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-302.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-302.png 544w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-302-300x38.png 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nano totalspendbycustomer.py\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #creates and opens file totalspendbycustomer.py<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"34\" class=\"wp-image-8938\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-303.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-303.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-303-300x16.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Paste in the following, which totals how much each customer spent:<\/p>\r\n<p>from pyspark import SparkConf, SparkContext<br \/><br \/>conf = SparkConf().setMaster(&#8220;local&#8221;).setAppName(&#8220;SpendByCustomer&#8221;)<br \/>sc = SparkContext(conf = conf)<br \/><br \/>def extractCustomerPricePairs(line):<br \/>\u00a0\u00a0\u00a0\u00a0fields = line.split(&#8220;,&#8221;)<br \/>\u00a0\u00a0\u00a0\u00a0return (int(fields[0]), float(fields[2]))<br \/><br \/>input = sc.textFile(&#8220;sparkdata\/customer-orders.csv&#8221;)<br \/>mappedInput = input.map(extractCustomerPricePairs)<br \/>totalByCustomer = mappedInput.reduceByKey(lambda x, y: x + y)<br \/><br \/>results = totalByCustomer.collect()<br \/>for result in results:<br \/>\u00a0\u00a0\u00a0\u00a0print(result)<\/p>\r\n<p>Save and exit the same way as before.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"372\" class=\"wp-image-8939\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-304.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-304.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-304-300x178.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>hadoop fs -put customer-orders.csv sparkdata<br \/>hadoop fs -ls sparkdata<br \/>spark-submit totalspendbycustomer.py<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"83\" class=\"wp-image-8940\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-305.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-305.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-305-300x40.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Each customer&#8217;s ID and total spend is displayed.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"312\" height=\"299\" class=\"wp-image-8941\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-306.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-306.png 312w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-306-300x288.png 300w\" sizes=\"auto, (max-width: 312px) 100vw, 312px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2>Example Three: The Single Most Popular Movie<\/h2>\r\n<p>cd<br \/>mkdir popularmovies<br \/>cd popularmovies<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"498\" height=\"71\" class=\"wp-image-8942\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-307.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-307.png 498w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-307-300x43.png 300w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 wget https:\/\/s3.amazonaws.com\/sankethadoop\/u.data \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To copy file to disk<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"188\" class=\"wp-image-8943\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-308.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-308.png 703w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-308-300x80.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nano popularmovies.py\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Open file popularmovies.py<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"662\" height=\"57\" class=\"wp-image-8944\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-309.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-309.png 662w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-309-300x26.png 300w\" sizes=\"auto, (max-width: 662px) 100vw, 662px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>Paste in the following, which counts votes per movie and sorts by popularity:<\/p>\r\n<p>from pyspark import SparkConf, SparkContext<br \/><br \/>conf = SparkConf().setMaster(&#8220;local&#8221;).setAppName(&#8220;PopularMovies&#8221;)<br \/>sc = SparkContext(conf = conf)<br \/><br \/>lines = sc.textFile(&#8220;sparkdata\/u.data&#8221;)<br \/>movies = lines.map(lambda x: (int(x.split()[1]), 1))<br \/>movieCounts = movies.reduceByKey(lambda x, y: x + y)<br \/><br \/>flipped = movieCounts.map(lambda xy: (xy[1], xy[0]))<br \/>sortedMovies = flipped.sortByKey()<br \/><br \/>results = sortedMovies.collect()<br \/>for result in results:<br \/>\u00a0\u00a0\u00a0\u00a0print(result)<\/p>\r\n<p>Save and exit, then load the data and run it:<\/p>\r\n<p>hadoop fs -put u.data sparkdata<br \/>spark-submit popularmovies.py<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"356\" class=\"wp-image-8945\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-310.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-310.png 638w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-310-300x167.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>It will show the most popular movie ID and most number of votes.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"453\" height=\"193\" class=\"wp-image-8946\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-311.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-311.png 453w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-311-300x128.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2>Example Four: The Top Ten Popular Movies, With Names<\/h2>\r\n<p>cd<br \/>mkdir 10popularmovies<br \/>cd 10popularmovies<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"512\" height=\"85\" class=\"wp-image-8947\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-312.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-312.png 512w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-312-300x50.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>wget https:\/\/s3.amazonaws.com\/sankethadoop\/u.item<br \/>wget https:\/\/s3.amazonaws.com\/sankethadoop\/u.data<\/p>\r\n<p>u.item maps each movie ID to its actual title, which the earlier examples never used.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"352\" class=\"wp-image-8948\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-313.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-313.png 703w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-313-300x150.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nano u.item\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To open the file content<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"54\" class=\"wp-image-8951\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-316.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-316.png 576w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-316-300x28.png 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>To exit press ctrl+ x<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"197\" class=\"wp-image-8949\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-314.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-314.png 497w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-314-300x119.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nano 10popular.py\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Create and open the file 10popular.py<\/p>\r\n\r\n\r\n\r\n<p>Paste the below code.<\/p>\r\n\r\n\r\n\r\n<p>from pyspark.sql import SparkSession<\/p>\r\n\r\n\r\n\r\n<p>from pyspark.sql import Row<\/p>\r\n\r\n\r\n\r\n<p>from pyspark.sql import functions<\/p>\r\n\r\n\r\n\r\n<p>def loadMovieNames():<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0 movieNames = {}<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0 with open(&#8220;<strong>\/home\/&lt;userid&gt;\/10popularmovies\/u.item<\/strong>&#8220;, encoding=&#8221;ISO-8859-1&#8221;) as f:<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 for line in f:<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fields = line.split(&#8216;|&#8217;)<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 movieNames[int(fields[0])] = fields [1]<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0 return movieNames<\/p>\r\n\r\n\r\n\r\n<p>spark = SparkSession.builder.appName(&#8220;PopularMovies&#8221;).getOrCreate()<\/p>\r\n\r\n\r\n\r\n<p>nameDict = loadMovieNames()<\/p>\r\n\r\n\r\n\r\n<p>lines = spark.sparkContext.textFile(&#8220;sparkdata\/u.data&#8221;)<\/p>\r\n\r\n\r\n\r\n<p>movies = lines.map(lambda x: Row(movieID =int(x.split()[1])))<\/p>\r\n\r\n\r\n\r\n<p>movieDataset = spark.createDataFrame(movies)<\/p>\r\n\r\n\r\n\r\n<p>topMovieIDs = movieDataset.groupBy(&#8220;movieID&#8221;).count().orderBy(&#8220;count&#8221;,ascending = False).cache()<\/p>\r\n\r\n\r\n\r\n<p>topMovieIDs.show()<\/p>\r\n\r\n\r\n\r\n<p>top10 = topMovieIDs.take(10)<\/p>\r\n\r\n\r\n\r\n<p>print(&#8220;\\n&#8221;)<\/p>\r\n\r\n\r\n\r\n<p>for result in top10:<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0 print(&#8220;%s: %d&#8221; % (nameDict[result[0]], result[1]))<\/p>\r\n\r\n\r\n\r\n<p>spark.stop()<\/p>\r\n\r\n\r\n\r\n<p>Change the highlighted area as your directory<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"383\" class=\"wp-image-8952\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-317.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-317.png 703w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-317-300x163.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop fs -put u.data sparkdata\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To copy u.data file into sparkdata<\/p>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop fs -ls sparkdata\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To display the content<\/p>\r\n\r\n\r\n\r\n<p>$\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 spark-submit 10popular.py\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #To execute the 10popular.py file<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"49\" class=\"wp-image-8953\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-318.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-318.png 703w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-318-300x21.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>It will display the most popular 10 movies.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"403\" height=\"731\" class=\"wp-image-8954\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-319.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-319.png 403w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-319-165x300.png 165w\" sizes=\"auto, (max-width: 403px) 100vw, 403px\" \/><\/figure>\r\n<h2>How These Four Examples Build on Each Other<\/h2>\r\n<p>Each example adds exactly one new idea rather than starting from scratch. The first counts values directly. The second maps each line into a key and value pair before combining them. The third flips a result to sort by count instead of by key. The fourth brings in a second file entirely, joining an ID based result against a lookup table to show real names instead of raw numbers, using the newer DataFrame API rather than plain RDDs. Working through them in order is worth more than jumping straight to the last one.<\/p>\r\n<h2>Common Mistakes to Avoid<\/h2>\r\n<ul>\r\n<li>Copying a script with curly quotation marks left in. Every string and dictionary key needs straight quotes to run.<\/li>\r\n<li>Forgetting to load each new file into HDFS before running its script. A script fails immediately if the data it expects is not there yet.<\/li>\r\n<li>Leaving the placeholder username in example four&#8217;s file path. It has to match your actual username exactly to find u.item.<\/li>\r\n<li>Relying on the personal S3 links here for anything beyond a one time exercise. Switch to the official GroupLens source if you are building something you plan to keep using.<\/li>\r\n<\/ul>\r\n<p>That covers four progressively more advanced Spark examples run directly on a Dataproc cluster. To go further, explore <a href=\"https:\/\/prwatech.in\/gcp-training-institutes-in-pune\/\"><strong><b>Prwatech&#8217;s Google Cloud training<\/b><\/strong>\u00a0program<\/a>, which includes placement assistance.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Working With Dataproc: Four Spark Examples Over SSH This runs four small Spark jobs directly on a Dataproc cluster&#8217;s master node over SSH, each a bit more involved than the last, counting movie ratings, totaling customer spending, finding the single most popular movie, then finding the top ten with their actual names attached. It complements [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1634,1],"tags":[1415,1412,1413,1414,1411,605,699,700,617,683,684,685,611,1400,692],"class_list":["post-8915","post","type-post","status-publish","format-standard","hentry","category-dataproc","category-google-cloud-platform","tag-dataproc","tag-dataproc-cluster","tag-dataproc-cluster-creation","tag-dataproc-cluster-properties","tag-dataproc-in-gcp","tag-gcp","tag-gcp-certification","tag-gcp-cloud-console","tag-google-cloud","tag-google-cloud-certification","tag-google-cloud-console","tag-google-cloud-courses","tag-google-cloud-platform","tag-google-cloud-platform-tutorial","tag-google-cloud-training"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Working With Dataproc: Four Spark Examples Over SSH<\/title>\n<meta name=\"description\" content=\"Run four progressively harder Spark examples directly on a Dataproc cluster over SSH, with every script&#039;s broken quotes fixed to run cleanly. Complete process\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working With Dataproc: Four Spark Examples Over SSH\" \/>\n<meta property=\"og:description\" content=\"Run four progressively harder Spark examples directly on a Dataproc cluster over SSH, with every script&#039;s broken quotes fixed to run cleanly. Complete process\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-21T05:41:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-22T16:22:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png\" \/>\n\t<meta property=\"og:image:width\" content=\"456\" \/>\n\t<meta property=\"og:image:height\" content=\"339\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/\",\"url\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/\",\"name\":\"Working With Dataproc: Four Spark Examples Over SSH\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png\",\"datePublished\":\"2026-09-21T05:41:44+00:00\",\"dateModified\":\"2026-09-22T16:22:11+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Run four progressively harder Spark examples directly on a Dataproc cluster over SSH, with every script's broken quotes fixed to run cleanly. Complete process\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png\",\"width\":456,\"height\":339},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Working with Dataproc\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Working With Dataproc: Four Spark Examples Over SSH","description":"Run four progressively harder Spark examples directly on a Dataproc cluster over SSH, with every script's broken quotes fixed to run cleanly. Complete process","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/","og_locale":"en_US","og_type":"article","og_title":"Working With Dataproc: Four Spark Examples Over SSH","og_description":"Run four progressively harder Spark examples directly on a Dataproc cluster over SSH, with every script's broken quotes fixed to run cleanly. Complete process","og_url":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-09-21T05:41:44+00:00","article_modified_time":"2026-09-22T16:22:11+00:00","og_image":[{"width":456,"height":339,"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png","type":"image\/png"}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/","url":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/","name":"Working With Dataproc: Four Spark Examples Over SSH","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png","datePublished":"2026-09-21T05:41:44+00:00","dateModified":"2026-09-22T16:22:11+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Run four progressively harder Spark examples directly on a Dataproc cluster over SSH, with every script's broken quotes fixed to run cleanly. Complete process","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-281.png","width":456,"height":339},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/dataproc\/working-with-dataproc\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Working with Dataproc"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/8915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=8915"}],"version-history":[{"count":4,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/8915\/revisions"}],"predecessor-version":[{"id":11845,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/8915\/revisions\/11845"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=8915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=8915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=8915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}