By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

Re: Insert character at a fixed position of lines

P: n/a

Francesco Pietra wrote:
How to insert letter "A" on each line (of a very long list of lines)
at position 22, i.e., one space after "LEU", leaving all other
characters at the same position as in the original example:
ATOM 1 N LEU 1 146.615 40.494 103.776 1.00 73.04 1SG 2

In all lines"ATOM" is constant as to both position and string, while
"LEU" is constant as to position only, i.e., "LEU" may be replaced by
three different uppercase letters. Therefore, the most direct
indication would be position 22.
you may find the fileinput module helpful, combined with the tips you've
already gotten in this thread.

reference:

http://docs.python.org/lib/module-fileinput.html

examples:

http://effbot.org/librarybook/fileinput.htm
http://blog.doughellmann.com/2007/03...fileinput.html

</F>

Jul 26 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.