Skip to content

Commit c05b65e

Browse files
author
ballima
committed
Create mapper.py
1 parent 76f7758 commit c05b65e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

mapper.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
#!/usr/bin/python
3+
4+
import sys
5+
6+
#for skipping data analysis on the first line
7+
for j, line in enumerate(sys.stdin, -1):
8+
if (j>=0):
9+
#taking each line into a variable "line"
10+
line = line.strip()
11+
#taking all the words in the line separated by comma to variable line
12+
words = line.split(",")
13+
count = 0
14+
length = len(words)
15+
#considering the last 5 elements of the array
16+
for i in reversed(words):
17+
if ( count < 5 and i != ""):
18+
print '%s\t%s' % (i, 1)
19+
count = count + 1
20+
~

0 commit comments

Comments
 (0)