Python Forum
Find specific subdir, open files and find specific lines that are missing from a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find specific subdir, open files and find specific lines that are missing from a file
#3
You could try something along the line of
import re

with open (hdir_f1) as cells_file:
    inum = set(int(match.group(1)) for match in
        (re.search(r"CELL\-(\d+)", line) for line in cells_file) if match)
    for i in range(1, 13):
        print('line CELL-{} - {}'.format(
            i, 'infile' if i in inum else 'missing'))
Reply


Messages In This Thread
RE: Find specific subdir, open files and find specific lines that are missing from a file - by Gribouillis - Aug-23-2020, 06:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Right way to open files with different encodings? Winfried 2 295 Apr-23-2024, 05:50 PM
Last Post: snippsat
  Open files in an existing window instead of new Kostov 2 369 Apr-13-2024, 07:22 AM
Last Post: Kostov
  delete specific row of entries jacksfrustration 3 433 Feb-13-2024, 11:13 PM
Last Post: deanhystad
  Extracting specific file from an archive tester_V 4 564 Jan-29-2024, 06:41 PM
Last Post: tester_V
  Open/save file on Android frohr 0 354 Jan-24-2024, 06:28 PM
Last Post: frohr
  Why can't I copy and past only ONE specific tab? NewWorldRonin 8 899 Jan-12-2024, 06:31 PM
Last Post: deanhystad
  data validation with specific regular expression shaheen07 0 366 Jan-12-2024, 07:56 AM
Last Post: shaheen07
  file open "file not found error" shanoger 8 1,213 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Can't Find Python (or Something) pklind 2 569 Nov-26-2023, 11:11 AM
Last Post: snippsat
  Can't Find Path hatflyer 8 1,120 Oct-30-2023, 06:17 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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