Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Jim ken

Ranch Hand
+ Follow
since Nov 29, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jim ken

Ok,hopefully with in next 24 hour some expert will resolve this issue on this forum.

1 year ago
experts, could you please advise now.
1 year ago
tried this but it's showig incorrect line no.
#importing required packages

import glob
from collections import Counter
import re
import xlwt
from xlwt import Workbook
import xlsxwriter
import xlrd
import errno
import time
from datetime import datetime
import datetime
import os
import os.path
import warnings
from xlutils.copy import copy
import openpyxl

# opening excel file

from xlrd import open_workbook

timestr = time.strftime("%Y%m%d-%H%M%S")

# path where all the folders and sub folders need to be searched.

yourpath = "D:\\mainfolder\\subfolders"

# location where excel containing all the keywords which are to be searched in above path.
loc = ("D:\\sample.xlsx")

cnt = Counter()
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
rows = sheet.nrows

# loop to pick up all the keywords from the column of excel one after another.

for i in range(1,rows):

# report to be generated in this location.

# report is opened in write mode.

FO = open(report_txt, 'w')

# structure layout of text file where records will be written.

str3="|"+"Pattern"+" "*(20-len("Pattern"))+"|"+"Vuernabilitiy  in file"+" "*(200-len("Vuernabilitiy  in file"))+"|"+"Line No"+" "*(10-len("Line No"))+"|" +"\n"

# main logic

for root, dirs, files in os.walk(yourpath, topdown=False):
   for name in files:
       path=os.path.join(root, name)
       files = glob.glob(path)
       for name in files:
                   with open(name,encoding="utf8",errors='ignore') as f:
                       text_string1 =
                       for i in range(0,len(excel_word)):
                           for num, line in enumerate(name, 1):
                               if excel_word[i] in text_string1:
                                   cnt[excel_word[i]] += 1
                                   str2="|"+excel_word[i]+" "*(20-len(excel_word[i]))+"|"+os.path.join(root, name)+" "*(200-len(os.path.join(root, name)))+"|"+str(num)+" "*(10-len(str(num)))+"|" +"\n"
               except IOError as exc:
                   if exc.errno != errno.EISDIR:

1 year ago
if no help can be offered then why this forum have been opened and code is self explanatory any python expert while reading it will be able to tell where is the mistake if this forum is not for help for users then what the benifit of this forum,this forum itself be closed.
1 year ago
Any updates please?
1 year ago
code is supposed to give result in a set format [keyword1,found in file name(at this lines),found in file name(at this line),(total found count of keyword1)] so for all the keywords which are listed in excel file column 'A' it should give these results that too in a graph format in html file (containing count etc. for keywords) but it's failing whle execution time itself giving 'invalid code identifier'.

1 year ago
ya, but any quick assistance would be much appreciated on this.

1 year ago
any updates by python experts please?
1 year ago
python experts could you please help on the same?
1 year ago
As stated earlier in this post script should be able to search all type of files like .txt,.yml,.xml,.html,.sh ...etc. in all the folders and subfolders for that given path in system's D drive and then finally be able to append the count column which has total counts for all the corresponding found keywords from this excel (Here let's say Column 'A' in this excel has all these keywords in it) so against column A it should list count and in next column it should list files where it found these key words and in next column it should list file names with the line nos for the found keyword.

1 year ago
also tried below script as well but it's also not working:-

import os
import glob

def search_words(keyword, target_dir):
   files = glob.glob(target_dir + '/**', recursive = True)
python_files = []
results = []
line_no = []# Isolate target files from folders and everything
   for f in files:
   if f.endswith('.py'):

for pyf in python_files:
   with open(pyf, 'rb') as f:
   lines = f.readlines()
for i, line in enumerate(lines):
   line = str(line)
if line.find(keyword) > -1:

   'keyword': keyword,
   'lines': line_no,
   'target_file': pyf,
   'total_found': len(line_no)
return results
1 year ago