Question

a program that takes a binary file and opens it and translates the data and prints...

a program that takes a binary file and opens it and translates the data and prints to a new text file. written in python

Homework Answers

Answer #1

For this I had downloaded a bin file online.i dont know about the data inside the bin file.

The file contains a list of numbers .

The name of the file is "sample.txt" placed inside the same folder as that of the program.

The code will simply open a bin file and reads the file saving all the data inside the bin file to a list

and then the list will be printed to a text file named "binwrite.txt" wher the data is printed line by line.

Provide the correctfile path for both the bin file and text file.

Code:


#Opening bin file to read
fr=open("sample.bin","rb")
#Opening text file to write
fw=open("binwrite.txt","w")
#reading the binary data converting it and placing them in a list
num=list(fr.read())
#writing the data to the txt file line by line
for i in num:
    fw.write(str(i)+"\n")
#closing the read file
fr.close()
#closing the write file
fw.close()

if the code is executed all the data inside the bin file will be converted and added to the text file

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
code that will take a binary file and searching for a byte pattern and then print...
code that will take a binary file and searching for a byte pattern and then print to a new text file. code written in python. printing the data from the binary to human legible text. prints data when pattern in found.
Create a Python program that opens and reads a csv file. Display csv file in legible...
Create a Python program that opens and reads a csv file. Display csv file in legible format. Include the program as a function.
Create a Python program that opens and reads an excel file (xlsx). Display excel file in...
Create a Python program that opens and reads an excel file (xlsx). Display excel file in legible format. Include the program as a function.
Write a Python program using that takes a number as input and then prints if the...
Write a Python program using that takes a number as input and then prints if the number is even or odd. The program should use a function isEven that takes a number as a parameter and returns a logical value true if the number is even, false otherwise.
Write a program in python that takes a txt file and converts it to html
Write a program in python that takes a txt file and converts it to html
C++ create a program that: in main: -opens the file provided for input (this file is...
C++ create a program that: in main: -opens the file provided for input (this file is titled 'Lab_HW10_Input.txt' and simply has 1-10, with each number on a new line for 10 lines total) -calls a function to determine how many lines are in the file -creates an array of the proper size -calls a function to read the file and populate the array -calls a function to write out the contents of the array in reverse order *output file should...
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...
Write a Java Program, that opens the file "students.txt" The program must read the file line...
Write a Java Program, that opens the file "students.txt" The program must read the file line by line The program parses each line that it reads For example, for this line: 1:mohamed:ali:0504123456:cs102:cs202 The program must print    >ID = 1    >First Name = Mohamed   >Last Name = Ali   >Mobie = 0504123456   >Courses = cs102, cs202 In addition, it adds the mobile phone number into an ArrayList called studentPhoneList Print the content and the size of studentPhoneList Show your results and provide...
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...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT