How to write mapper code for Hadoop in Python

0 votes

Hi Team,

I am new to Hadoop. I want to write the mapper code in python language. How can I do that?

Oct 16, 2020 in Big Data Hadoop by akhtar
• 38,260 points
779 views

1 answer to this question.

0 votes

Hi@akhtar,

Any job in Hadoop must have two phases: one is a mapper and another one is a reducer. You can write codes for the mapper in python script to run it under Hadoop. I have attached one script below for your reference.

!/usr/bin/python
import sys
# Input takes from standard input for myline in sys.stdin: 
   # Remove whitespace either side 
   myline = myline.strip() 
   # Break the line into words 
   words = myline.split() 
   # Iterate the words list
   for myword in words:
      # Write the results to standard output 
      print '%s\t%s' % (myword, 1)
answered Oct 16, 2020 by MD
• 95,460 points

Related Questions In Big Data Hadoop

+1 vote
2 answers

How to authenticate username & password while using Connector for Cloudera Hadoop in Tableau?

Hadoop server installed was kerberos enabled server. ...READ MORE

answered Aug 21, 2018 in Big Data Hadoop by Priyaj
• 58,020 points
1,714 views
0 votes
1 answer

How to create a project for the first time in Hadoop.?

If you want to learn Hadoop framework ...READ MORE

answered Jul 27, 2018 in Big Data Hadoop by Neha
• 6,300 points
1,182 views
0 votes
1 answer

What is Custom partitioner in Hadoop? How to write partition function ?

Don't think that in Hadoop the same ...READ MORE

answered Sep 18, 2018 in Big Data Hadoop by Frankie
• 9,830 points
1,579 views
0 votes
1 answer

How to execute python script in hadoop file system (hdfs)?

If you are simply looking to distribute ...READ MORE

answered Sep 19, 2018 in Big Data Hadoop by digger
• 26,740 points
13,575 views
0 votes
1 answer

When is an identity mapper/reducer used?

1.One of the simplest example of Iterative ...READ MORE

answered Apr 3, 2018 in Big Data Hadoop by Ashish
• 2,650 points
2,223 views
0 votes
1 answer

What is the command to find the free space in HDFS?

You can use dfsadmin which runs a ...READ MORE

answered Apr 29, 2018 in Big Data Hadoop by Shubham
• 13,490 points
2,224 views
0 votes
1 answer

How to find the used cache in HDFS

hdfs dfsadmin -report This command tells fs ...READ MORE

answered May 4, 2018 in Big Data Hadoop by Shubham
• 13,490 points
2,493 views
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
11,067 views
0 votes
1 answer

How to write Reducer code for Hadoop?

Hi@akhtar, You can create a reducer code for ...READ MORE

answered Oct 16, 2020 in Big Data Hadoop by MD
• 95,460 points
881 views
0 votes
2 answers

How to set properties for secondary namenode in Hadoop?

Secondary NameNode in HDFS Secondary NameNode in Hadoop ...READ MORE

answered Mar 31, 2020 in Big Data Hadoop by anonymous
4,300 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP