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?
Asked
Active
Viewed 87 times
1 Answers
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