Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:01:53+00:00 2026-06-05T18:01:53+00:00

I have a directory OUTPUT where I have the output files from a Map

  • 0

I have a directory OUTPUT where I have the output files from a Map Reduce job. The output files are Text files written with a TextOutputFormat.

Now I want to read the key value pairs from the output file. How can I do so using some existing classes in hadoop. One way I could do it was as follows

FileSystem fs = FileSystem.get(conf);
FileStatus[] files = fs.globStatus(new Path(OUTPUT + "/part-*"));
for(FileStatus file:files){
  if(file.getLen() > 0){
    FSDataInputStream in = fs.open(file.getPath());
    BufferedReader bin = new BufferedReader(new InputStreamReader(
        in));
    String s = bin.readLine();
    while(s!=null){
      System.out.println(s);
      s = bin.readLine();
    }
    in.close();
  }
}

This approach would work but increases my task to a great deal as I now need to manually parse the key value pairs out of each individual line. I am looking for something more handy that directly lets me read key and value in some variables.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:01:56+00:00Added an answer on June 5, 2026 at 6:01 pm

    Are you forced to use TextOutputFormat as your output format in the previous job?

    If not then consider using SequenceFileOutputFormat, then you can use a SequenceFile.Reader to read back the file in Key / Value pairs. You can also still ‘view’ the file using hadoop fs -text path/to/output/part-r-00000

    EDIT: You can also use the KeyValueLineRecordReader class, you’ll just need to pass in a FileSplit to teh constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VS2008 I want to copy certain files from a directory into
I have created a directory structure with an executable file. Following is the output
I have directory with > 1000 .html files, and would like to check all
I have directory A with files matching directory B. Directory A may have other
To piggyback onto this question, PowerShell script to delete files from list and output
I have to download some files from an FTP server. Seems prosaic enough. However,
I have a shell function that is called from inside my map function. The
I have a directory which contains externally maintained html help files for a Visual
I have a directory structure with 50,000+ files. The filenames are of the form
I'd like to be able to list files from a distant directory on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.