Reputation: 3
How to insert 10 spaces in front of data.txt arrange like this
0.00E+00 0.00E+00
1.00E-02 1.91E-10
2.00E-02 5.97E-10
3.01E-02 2.80E-10
4.01E-02 2.58E-10
I have used this code from python programmer post
with open("data.txt", "r") as rf:
with open("data_copy3.txt", "w") as wf:
for line in rf:
wf.write(line)
I tried {:>10}
but couldn't insert the space into the new data_copy3.txt
The new file should be arranged like:
0.00E+00 0.00E+00
1.00E-02 1.91E-10
2.00E-02 5.97E-10
3.01E-02 2.80E-10
4.01E-02 2.58E-10
The original file is in the same format, just without 10 spaces in the beginning of each line.
Upvotes: 0
Views: 39
Reputation: 8571
Just print whatever you want in the loop, e.g.:
with open("data.txt", "r") as rf:
with open("data_copy3.txt", "w") as wf:
for line in rf:
wf.write(" " + line)
Upvotes: 1