0

this question has a lot to do with the following one:

Getting Raw Binary Representation of a file in Python

with the following python code, i can now turn a testfile.txt file into the binary version with these lines:

bytetable = [("00000000"+bin(x)[2:])[-1:-9:-1] for x in range(256)]

binrep = "".join(bytetable[x] for x in open("testfile.txt", "rb").read())

My question is, how do I return it back to normal afterwards? I want to take the binary, in this case 110011101111011010110110101001100000010000101110101001100001111000101110 and re-create testfile.txt from it. If this is possible, let me know.

5
  • does it have to be in python? Commented Jan 2, 2014 at 22:45
  • Note the "So far, I have this" part to the linked question, which you're missing. Also, if you want it in Python, you should add the python tag. If you want it in any language, you should pick one language, and add that tag. Commented Jan 2, 2014 at 22:54
  • Did you see the comment in the linked question pointing to this question? - Convert Binary to ASCII and vice versa (Python) (possible duplicate?) Commented Jan 2, 2014 at 22:59
  • this is my first post, sorry about the mistakes. i added the tag and edited the question to be more specific. Dukeling, the stackoverflow.com/questions/7396849/… thread is not the same, i want to re-create the text file from the binary representation of that file, not convert to text. i will play around with the reverse that is suggested in the comment for that thread and see if the file is re-created, not sure if it will work though. ultimately i want to be able to take any file and convert it back and forth. thanks Commented Jan 3, 2014 at 16:08
  • Jona, it would be nice to do this in python, but if you know how to do this in a different language, i would be interested in seeing that as well. Commented Jan 3, 2014 at 18:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.