Python Forum
Cloning a directory and using a .CSV file as a reference to search and replace
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cloning a directory and using a .CSV file as a reference to search and replace
#1
Hello I am trying to clone a directory with text files (XML, L5X, txt, etc). I would like to build something that would reference a .CSV with what text I would like to search for in column A and what I would like to replace that text with in column B. I would like my code to then copy all the text files in that folder and use the excel spreadsheet to make all the search and replacements of the file directory all in one pass instead of search and replace each file individually.

How would I go about doing this? What python methods are out there that would help with this? There's some material online that shows how to make changes to a single string of text but not much on mass search and replace referencing the csv/spreadsheet.

Any suggestions or reference code to do this to put me on the right track would be greatly appreciated!

Thank you
Reply


Messages In This Thread
Cloning a directory and using a .CSV file as a reference to search and replace - by bg25lam - May-31-2021, 04:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] [Beautiful Soup] Replace tag.string from another file? Winfried 2 648 May-01-2025, 03:43 PM
Last Post: Winfried
  Replace values in Yaml file with value in dictionary PelleH 1 2,457 Feb-11-2025, 09:51 AM
Last Post: alexjordan
  How to read a file as binary or hex "string" so that I can do regex search? tatahuft 3 1,473 Dec-19-2024, 11:57 AM
Last Post: snippsat
  Search in a file using regular expressions ADELE80 2 938 Dec-18-2024, 12:29 PM
Last Post: ADELE80
  Running search/replace across Polars dataframe columns efficiently hobbycoder 3 2,707 Oct-28-2024, 03:18 AM
Last Post: hobbycoder
  FileNotFoundError: [Errno 2] No such file or directory although the file exists Arnibandyo 0 1,357 Aug-12-2024, 09:11 AM
Last Post: Arnibandyo
  "[Errno 2] No such file or directory" (.py file) IbrahimBennani 13 7,424 Jun-17-2024, 12:26 AM
Last Post: AdamHensley
  Search Excel File with a list of values huzzug 4 3,086 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Replace a text/word in docx file using Python Devan 4 25,906 Oct-17-2023, 06:03 PM
Last Post: Devan
  Need to replace a string with a file (HTML file) tester_V 1 2,076 Aug-30-2023, 03:42 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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