Python Forum
writing in particular positions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
writing in particular positions
#4
You would want something like this:

with open('old_file.txt') as in_file:
    with open('new_file.txt, 'w') as out_file:
        for line in old_file:
            new_file.write(line)
            if new_file.startswith('@<TRIPOS>MOLECULE'):
                new_file.write('MOLECULE NAME')
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
writing in particular positions - by clarablanes - Apr-13-2019, 09:39 AM
RE: writing in particular positions - by ichabod801 - Apr-13-2019, 12:57 PM
RE: writing in particular positions - by ichabod801 - Apr-13-2019, 01:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding Sliced Positions Gizzmo28 1 1,621 Nov-05-2020, 02:46 AM
Last Post: bowlofred
  Read characters of line and return positions Gizzmo28 2 2,067 Nov-04-2020, 09:27 AM
Last Post: perfringo
  Print different positions in loop from functions konsular 5 2,758 Oct-16-2019, 08:10 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020