Skip to content

Commit a9e4f71

Browse files
Updated notebooks
1 parent bc959b0 commit a9e4f71

File tree

180 files changed

+13447
-1067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+13447
-1067
lines changed

1_start/.ipynb_checkpoints/First Twitter App-checkpoint.ipynb

Lines changed: 26 additions & 14 deletions
Large diffs are not rendered by default.

1_start/First Twitter App.ipynb

Lines changed: 26 additions & 14 deletions
Large diffs are not rendered by default.

1_start/TweetRead.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def __init__(self, csocket):
2121
def on_data(self, data):
2222
try:
2323
msg = json.loads( data )
24-
print( msg['text'].encode('utf-8') )
25-
self.client_socket.send( msg['text'].encode('utf-8') )
24+
print(msg['text'].encode('utf-8'))
25+
self.client_socket.send( msg['text'].encode('utf-8'))
2626
return True
2727
except BaseException as e:
2828
print("Error on_data: %s" % str(e))
@@ -40,7 +40,7 @@ def sendData(c_socket):
4040
twitter_stream.filter(track=['football'])
4141

4242
if __name__ == "__main__":
43-
s = socket.socket() # Create a socket object
43+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Create a socket object
4444
host = "127.0.0.1" # Get local machine name
4545
port = 5555 # Reserve a port for your service.
4646
s.bind((host, port)) # Bind to the port
@@ -50,6 +50,6 @@ def sendData(c_socket):
5050
s.listen(5) # Now wait for client connection.
5151
c, addr = s.accept() # Establish connection with client.
5252

53-
print( "Received request from: " + str( addr ) )
53+
print("Received request from: " + str(addr))
5454

55-
sendData( c )
55+
sendData(c)

2_basics/.ipynb_checkpoints/01_Queue of RDDs as a Stream-checkpoint.ipynb

Lines changed: 92 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,98 @@
4848
},
4949
{
5050
"cell_type": "code",
51-
"execution_count": null,
52-
"metadata": {
53-
"collapsed": true
54-
},
55-
"outputs": [],
51+
"execution_count": 3,
52+
"metadata": {},
53+
"outputs": [
54+
{
55+
"name": "stdout",
56+
"output_type": "stream",
57+
"text": [
58+
"-------------------------------------------\n",
59+
"Time: 2018-01-17 17:16:21\n",
60+
"-------------------------------------------\n",
61+
"(0, 100)\n",
62+
"(8, 100)\n",
63+
"(2, 100)\n",
64+
"(4, 100)\n",
65+
"(6, 100)\n",
66+
"(1, 100)\n",
67+
"(3, 100)\n",
68+
"(9, 100)\n",
69+
"(5, 100)\n",
70+
"(7, 100)\n",
71+
"\n",
72+
"-------------------------------------------\n",
73+
"Time: 2018-01-17 17:16:22\n",
74+
"-------------------------------------------\n",
75+
"(0, 100)\n",
76+
"(8, 100)\n",
77+
"(2, 100)\n",
78+
"(4, 100)\n",
79+
"(6, 100)\n",
80+
"(1, 100)\n",
81+
"(3, 100)\n",
82+
"(9, 100)\n",
83+
"(5, 100)\n",
84+
"(7, 100)\n",
85+
"\n",
86+
"-------------------------------------------\n",
87+
"Time: 2018-01-17 17:16:23\n",
88+
"-------------------------------------------\n",
89+
"(0, 100)\n",
90+
"(8, 100)\n",
91+
"(2, 100)\n",
92+
"(4, 100)\n",
93+
"(6, 100)\n",
94+
"(1, 100)\n",
95+
"(3, 100)\n",
96+
"(9, 100)\n",
97+
"(5, 100)\n",
98+
"(7, 100)\n",
99+
"\n",
100+
"-------------------------------------------\n",
101+
"Time: 2018-01-17 17:16:24\n",
102+
"-------------------------------------------\n",
103+
"(0, 100)\n",
104+
"(8, 100)\n",
105+
"(2, 100)\n",
106+
"(4, 100)\n",
107+
"(6, 100)\n",
108+
"(1, 100)\n",
109+
"(3, 100)\n",
110+
"(9, 100)\n",
111+
"(5, 100)\n",
112+
"(7, 100)\n",
113+
"\n",
114+
"-------------------------------------------\n",
115+
"Time: 2018-01-17 17:16:25\n",
116+
"-------------------------------------------\n",
117+
"(0, 100)\n",
118+
"(8, 100)\n",
119+
"(2, 100)\n",
120+
"(4, 100)\n",
121+
"(6, 100)\n",
122+
"(1, 100)\n",
123+
"(3, 100)\n",
124+
"(9, 100)\n",
125+
"(5, 100)\n",
126+
"(7, 100)\n",
127+
"\n",
128+
"-------------------------------------------\n",
129+
"Time: 2018-01-17 17:16:26\n",
130+
"-------------------------------------------\n",
131+
"\n",
132+
"-------------------------------------------\n",
133+
"Time: 2018-01-17 17:16:27\n",
134+
"-------------------------------------------\n",
135+
"\n",
136+
"-------------------------------------------\n",
137+
"Time: 2018-01-17 17:16:28\n",
138+
"-------------------------------------------\n",
139+
"\n"
140+
]
141+
}
142+
],
56143
"source": [
57144
"if __name__ == \"__main__\":\n",
58145
" sc = SparkContext(appName=\"PythonStreamingQueueStream\")\n",

0 commit comments

Comments
 (0)