Python Forum
splitting file into multiple files by searching for string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
splitting file into multiple files by searching for string
#1
Hello everybody,

I got a backup of a bunch of chess games (from chess.com) I played with a friend of mine and wanted to save them as individual files. Now I only have a complete file with all games but I noticed, that every individual game begins with the string "[Event "Let's Play!"]".

Now I want to create a python script which checks for the string and saves everything to a file until the string occurs again, but I'm not sure how to do so. I thought of using a for-loop which looks for the string, saves everything to a file (with increasing counter) until the string comes again and the loop repeats.

My first problem is, how take only the "difference" between the string?
Reply


Messages In This Thread
splitting file into multiple files by searching for string - by AlphaInc - Jul-01-2023, 10:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python convert multiple files to multiple lists MCL169 6 1,629 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  Need to replace a string with a file (HTML file) tester_V 1 796 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Splitting vocals from .wav file cfescript 1 655 May-15-2023, 09:28 PM
Last Post: Calab
  Merging multiple csv files with same X,Y,Z in each Auz_Pete 3 1,224 Feb-21-2023, 04:21 AM
Last Post: Auz_Pete
  unittest generates multiple files for each of my test case, how do I change to 1 file zsousa 0 985 Feb-15-2023, 05:34 PM
Last Post: zsousa
  Find duplicate files in multiple directories Pavel_47 9 3,222 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  Splitting code into several files TLammert 4 1,526 Jun-26-2022, 02:33 PM
Last Post: TLammert
  Matching multiple parts in string fozz 31 6,503 Jun-13-2022, 09:38 AM
Last Post: fozz
  Extract parts of multiple log-files and put it in a dataframe hasiro 4 2,120 Apr-27-2022, 12:44 PM
Last Post: hasiro
  Search multiple CSV files for a string or strings cubangt 7 8,173 Feb-23-2022, 12:53 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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