Question

Write a python code to print (any given file) file as a csv format by using...

Write a python code to print (any given file) file as a csv format by using MRJob only. code must be able to run stand-alone MRJob application.
For submission to your work: Your final hand should be a single file name BDM.py that takes exactly one arguments for the input path. output will be handled through redirection.
Sample run: python BDM.py sample.csv > output.csv

Homework Answers

Answer #1

First of all to using the MRJob, You will have to install MRJob. To install MRJob, You must have pip3 installed (If you already installed, you can skip this). To install use - pip3 install mrjob

from mrjob.job import MRJob
class BDM(MRJob):

    def converter(self, _, line):
        id, address = line.split(',')
      
        //extract anything from the input.csv
        //add it here and yield/print it
        
        yield id, temporary 

if __name__ == '__main__':
     BDM.run()

Your CSV should look like this --->


1, "81 Gourav Sardana, Bengaluru, KR"
2, "44 Near semeston garden, New York, NY"

To run this, use the same format as you suggested in your question i.e python3 BDM.py input.csv >output.csv

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a program that filters the data in a CSV file of product data based on...
Create a program that filters the data in a CSV file of product data based on some search word and prints the resulting output to a new file. Additionally, the program will print the number of items filtered to stdout. • Your program should take three arguments: an input file to process, an output file to save the results, and a search word. • If the output file already exists or cannot be opened, warn the user by printing "CANNOT...
C++ programming Write a program that reads a comma-separated file (CSV) with integer values and prints...
C++ programming Write a program that reads a comma-separated file (CSV) with integer values and prints the number of integer values in the file. Your program's input will be a string with the name of the file. If the file does not exist, then the program must print: Error opening the file For example, given the following CSV file input1.csv: 1,10,20,30,40 The output of your program must be: 5 You can safely assume that the input file will be a...
I need python code for this. Write a program that inputs a text file. The program...
I need python code for this. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase words should take precedence over lowercase words. For example, 'Z' comes before 'a'. The input file can contain one or more sentences, or be a multiline list of words. An example input file is shown below: example.txt the quick brown fox jumps over the lazy dog An example of the program's output...
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED....
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED. ALSO THE 2 POINTS MENTIONED BELOW SHOULD BE PRESENT IN THE CODE Write a script that calculates the 3 longest words of a text stored in a file and print them from the longest to the smaller of the 3. Please note: 1. The name of the file is word_list.csv and it doesn’t need to be asked to the user (meaning the name will...
python code We're using structs and focusing on binary file I/O def read_attributes(file_path, format): """ Given...
python code We're using structs and focusing on binary file I/O def read_attributes(file_path, format): """ Given a binary file written using struct.pack() with the given format, return the number of bytes in the file and the number of bytes in each chunk. :param file_path: :param format: a string with the format of the data in the struct :return: tuple with the number of bytes in file and the number of bytes written in each chunk """
By using Python code answer the following parts: A) Write a program to ask the user...
By using Python code answer the following parts: A) Write a program to ask the user to input their name and then output the type and length of the input. B) Write a program to output the last 11 letters of 'Introduction to Indiana'. C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'. D) Write a program to ask the user to input a float number and output the rounded value of it...
Create a program that copies the data from one file to another while converting all lowercase...
Create a program that copies the data from one file to another while converting all lowercase vowels to uppercase vowels. Your program should accept two arguments: an input file to read from and an output file to copy to. • Your program should check to make sure the output file does not already exist. If it does, print "DESTINATION FILE EXISTS." to stdout. • Print the number of characters changed to stdout using the format string "%d characters changed." •...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
So, i have this code in python that i'm running. The input file is named input2.txt...
So, i have this code in python that i'm running. The input file is named input2.txt and looks like 1.8 4.5 1.1 2.1 9.8 7.6 11.32 3.2 0.5 6.5 The output2.txt is what i'm trying to achieve but when the code runs is comes up blank The output doc is created and the code doesn't error out. it should look like this Sample Program Output 70 - 510, [semester] [year] NAME: [put your name here] PROGRAMMING ASSIGN MENT #2 Enter...
The following code to run as the described program on python. The extra test file isn't...
The following code to run as the described program on python. The extra test file isn't included here, assume it is a text file named "TXT" with a series of numbers for this purpose. In this lab you will need to take a test file Your program must include: Write a python program to open the test file provided. You will read in the numbers contained in the file and provide a total for the numbers as well as the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT