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.

Community
  • 1
  • 1
ahetman
  • 1,274
  • 11
  • 17
  • does it have to be in python? – Jona Jan 02 '14 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 [tag:python] [tag](http://stackoverflow.com/help/tagging). If you want it in any language, you should pick *one* language, and add that tag. – Bernhard Barker Jan 02 '14 at 22:54
  • Did you see the comment in the linked question pointing to this question? - [Convert Binary to ASCII and vice versa (Python)](http://stackoverflow.com/q/7396849) (possible duplicate?) – Bernhard Barker Jan 02 '14 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 http://stackoverflow.com/questions/7396849/convert-binary-to-ascii-and-vice-versa-python 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 – ahetman Jan 03 '14 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. – ahetman Jan 03 '14 at 18:10

0 Answers0