GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — LearnPython/FindMissingFileNumbersOptimized_10000.py at master · Pragad/LearnPython Expand file tree/ Copy pathFindMissingFileNumbersOptimized_10000.pyMore file actions 53 lines (47 loc) · 1.88 KB / Copy pathFindMissingFileNumbersOptimized_10000.pyFile metadata and controls53 lines (47 loc) · 1.88 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 #! /usr/bin/env/python import mmap import re #------------------------------------------------------------------------------------------- # Main Function #------------------------------------------------------------------------------------------- def main(): filePath = input("Enter file path: ") endFileNum = input("Enter end file number: ") filesMissingCount = 0 filesPresentCount = 0 fileNumbersMissing = set() filesNumbersPresent = set() fileNamesPresent = set() #>>> myRegex=r'(.*)file_(.)' + re.escape(str(TEXTTO)) + r'\.txt' #>>> searchObj=re.search(myRegex,line) #>>> print(searchObj) #<_sre.SRE_Match object; span=(0, 15), match='asdffile__0.txt'> # https://stackoverflow.com/questions/46476537/python-how-to-search-a-string-in-a-large-file #my_regex = re.compile('.*file_.(\d+)\.txt.*') my_regex = re.compile('.*file(\d+)\.txt.*') for line in open(filePath): match = my_regex.search(line) if match: filesNumbersPresent.add(int(match.group(1))) #start = line.find('file_') start = line.find('file') end = line.find('txt', start) fileNamesPresent.add(line[start:end+3]) for x in range(int(endFileNum)): if x not in filesNumbersPresent: fileNumbersMissing.add(x) filesMissingCount += 1 else: filesPresentCount += 1 print("Files Present: ") #print(fileNamesPresent) #print(filesNumbersPresent) print("Files Present Count: %d" % filesPresentCount) print("Files Missing: ") print(fileNumbersMissing) print("Files Missing Count: %d" % filesMissingCount) #------------------------------------------------------------------------------------------- # Start Main #------------------------------------------------------------------------------------------- if __name__ == "__main__": main() |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |