Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comapring two files
#4
As a suggestion, look into Python's "re" module (regex). Then you could match line by line from both files.

See here for more suggestions.

Also here for how to iterate through a file.

import re

s1 = "2019-10-03 text in the source file"
s2 = "2019-10-03 text from the file to be searched"

matches = re.search("^(\d{4}-\d{1,2}-\d{1,2})(.*)$", s1)
print(matches.group(1))

# Then use an if in
if matches.group(1) in s2:
    matches = re.search("^(\d{4}-\d{1,2}-\d{1,2})(.*)$", s2)
    print(matches.group(2))
Reply


Messages In This Thread
Comapring two files - by usman88 - Oct-02-2019, 08:11 PM
RE: Comapring two files - by micseydel - Oct-02-2019, 09:39 PM
RE: Comapring two files - by usman88 - Oct-03-2019, 06:38 AM
RE: Comapring two files - by burningkrome - Oct-03-2019, 11:41 AM
RE: Comapring two files - by usman88 - Oct-03-2019, 01:58 PM
RE: Comapring two files - by burningkrome - Oct-03-2019, 04:29 PM
RE: Comapring two files - by usman88 - Oct-07-2019, 09:46 AM
RE: Comapring two files - by wavic - Oct-07-2019, 10:20 AM

Forum Jump:

User Panel Messages

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