-2

I have a big file with 4 numbers in every row. Now I want that before every number there will be added 8 zeros. How can I do that in Bash or Python?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Craxxurz
  • 105
  • 8

1 Answers1

0

This should work:

myfile = open("filename.txt")
items = myfile.read().split("\n")
mystr = ""
for x in range(0, len(items)):
    mystr += "00000000" + items[x] + "\n"
myfile = open("filename.txt", 'w')
myfile.write(mystr)
myfile.close()
Bennett
  • 1,007
  • 4
  • 15
  • 29