2

Using MRJob library, the output of reducer is printed in the console and stdout is the default output. How can I specify a file for output so instead of being printed, results will be written in that file.

EDIT: There is another question asking for csv output format, but my question is simpler and is just to write the output as it is in a file instead of printing it which I think should be simple and do not require using any axillary package!

Dandelion
  • 744
  • 2
  • 13
  • 34
  • 1
    Possible duplicate of [MRJob and python - .csv file output for Reducer?](https://stackoverflow.com/questions/31032885/mrjob-and-python-csv-file-output-for-reducer) – backtrack Dec 11 '18 at 10:18
  • As the answer to that proposed duplicate explains, "To manage input and output formats in mrjob, *you need to use protocols*." It's not the difference between "write to a file instead of printing it" that counts here. – Jongware Dec 11 '18 at 13:07
  • 1
    I'v found a solution using terminal command ">" to redirect output to a file!!! – Dandelion Dec 11 '18 at 13:22
  • @usr2564301 yes but the explanation is in the link and I'm afraid that I couldn't use the documentation to get the output in a file! – Dandelion Dec 11 '18 at 13:25

2 Answers2

0

To run locally from the command line:

$ python MRJob.py < input_file > output_file
0

What worked for me in cmd / powershell was the following command:

python .\MRJob.py input_file > output_file

NOTE that I did NOT use '<' before the input_file. That lead to my terminal throwing an error

Jonas
  • 41
  • 1
  • 6