Python Forum
Help with python code to search string in one file & replace with line in other file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with python code to search string in one file & replace with line in other file
#23
OK, re-do everything in post 15.
This will work in python 2.7, but you have to run from the command line like:
c:\Python27\python.exe SwapHeaders.py -i 'File1.txt' -b 'File2.txt' -o 'Fileout.txt'
replacing the python command to point to your python 2.7 directory
and changing file names as appropriate.

running:
c:\Python27\python.exe SwapHeaders.py -h
As an aid, will give you:
Output:
usage: SwapHeaders.py [-h] [-i ORIGINAL_FILENAME]                       [-b REPLACE_ORIGINAL_FILENAME] [-o OUT_FILENAME] optional arguments:   -h, --help            show this help message and exit   -i ORIGINAL_FILENAME, --ifile ORIGINAL_FILENAME                         Filename where headers are to be replaced   -b REPLACE_ORIGINAL_FILENAME, --bfile REPLACE_ORIGINAL_FILENAME                         Filename containing body   -o OUT_FILENAME, --ofile OUT_FILENAME                         Output filename
Reply


Messages In This Thread
RE: Help with python code to search string in one file & replace with line in other file - by Larz60+ - Dec-18-2017, 11:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python coding to run file NSR115 1 217 Jun-18-2024, 11:05 AM
Last Post: Kajalishu
  "[Errno 2] No such file or directory" (.py file) IbrahimBennani 13 815 Jun-17-2024, 12:26 AM
Last Post: AdamHensley
  Printing the code line number arbiel 2 286 Jun-15-2024, 07:37 PM
Last Post: arbiel
  Replace values in Yaml file with value in dictionary PelleH 0 168 Jun-12-2024, 02:40 PM
Last Post: PelleH
  Cannot get cmd to print Python file Schauster 11 733 May-16-2024, 04:40 PM
Last Post: xMaxrayx
  Matching string from a file tester_V 5 656 Mar-05-2024, 05:46 AM
Last Post: Danishhafeez
  Python openyxl not updating Excel file MrBean12 1 533 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 546 Feb-15-2024, 11:15 AM
Last Post: rawatg
  Unable to understand the meaning of the line of code. jahuja73 0 448 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  connect sql by python using txt. file dawid294 2 602 Jan-12-2024, 08:54 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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