2

How to run Hadoop wordcount program on pdf and doc files? When I try to run it on pdf files the output shows weird characters.

2 Answers2

2

The file formats you mentioned are binary and not suitable as input to word count without pre-processing them into plain text. You will first have to convert them using some other tool/library into a plain text format.

There are probably some free command-line utilities out there which can help you do this.

Javanator
  • 109
  • 6
  • The statement that binary file formats are not suitable as input and you would need to convert to plain text is completely wrong, the most efficient Hadoop programs use binary input as it avoid the need of parsing the input and thus increases efficiency. – Charles Menguy Mar 09 '13 at 20:18
2

Hadoop is not limited to processing clear-text files, you can of course process binary files, for example SequenceFiles are the most common binary format in Hadoop, but if you want a custom binary format you can also do it by implementing your own InputFormat and RecordReader.

I would recommend looking at this great article on processing .doc files in Hadoop, and this one on processing .docx and .pdf files, which should fit your needs.

Charles Menguy
  • 40,830
  • 17
  • 95
  • 117