Python Forum
Replace based on values in a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace based on values in a file
#3
I would try re.sub. You might be able to do it with just one command, but "1 Sam" may cayse problems. This could also be done using str.replace(), but matching only complete words might be difficult.

Either way I would treat the file like one long string instead of a line at a time.
Reply


Messages In This Thread
Replace based on values in a file - by WJSwan - Jan-30-2023, 05:45 AM
RE: Replace based on values in a file - by WJSwan - Jan-30-2023, 09:00 AM
RE: Replace based on values in a file - by deanhystad - Jan-30-2023, 04:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting data based on DataFrames values 577e94982d620b84f7c536d5e76f1e 0 2,055 Dec-03-2018, 02:23 AM
Last Post: 577e94982d620b84f7c536d5e76f1e
  file a table of values Ybivashka322 4 3,719 Dec-14-2017, 06:11 PM
Last Post: mpd
  logic comparater based on dictionary values ijosefson 3 3,241 Oct-16-2017, 06:04 AM
Last Post: Mekire

Forum Jump:

User Panel Messages

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