Python Forum
How To Find an Opening and Closing String, Copying Open/Close/Contents to New File
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How To Find an Opening and Closing String, Copying Open/Close/Contents to New File
#1
Hi All,

I want to use Python to parse some old BASIC code. Basically, I'm looking to locate each subroutine within the source file and then copy each subroutine out into a new file named after the subroutine.

I imagine it would go something like this:
1. Find a string containing sub nameofsub
2. Find the matching end sub for this subroutine
3. Create a new file with the name of the subroutine.
4. Copy the contents of the opening and closing strings and all contained text into this new file.
5. Repeat from the beginning.
Reply


Messages In This Thread
How To Find an Opening and Closing String, Copying Open/Close/Contents to New File - by davidshq - Mar-01-2020, 08:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help copying a column from a csv to another file with some extras g0nz0uk 3 455 Feb-01-2024, 03:12 PM
Last Post: DeaD_EyE
  Open/save file on Android frohr 0 313 Jan-24-2024, 06:28 PM
Last Post: frohr
  file open "file not found error" shanoger 8 1,087 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Need to replace a string with a file (HTML file) tester_V 1 760 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  How can i combine these two functions so i only open the file once? cubangt 4 851 Aug-14-2023, 05:04 PM
Last Post: snippsat
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 1,560 Jul-31-2023, 11:42 AM
Last Post: deanhystad
  Cannot find py credentials file standenman 5 1,630 Feb-25-2023, 08:30 PM
Last Post: Jeff900
  Save and Close Excel File avd88 0 3,006 Feb-20-2023, 07:19 PM
Last Post: avd88
  selenium can't find a file in my desk ? SouAmego22 0 738 Feb-14-2023, 03:21 PM
Last Post: SouAmego22
  I cannot able open a file in python ? ted 5 3,282 Feb-11-2023, 02:38 AM
Last Post: ted

Forum Jump:

User Panel Messages

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