Is python provide search in parent folder contain subfolders and files
for example folder name is cars and subfile is Toyota,Honda and BMW and Toyota contain file name camry and file name corola, file name honda contain folder accord and BMW contain file name X5

Is there way to enter name of parent folder(cars) and search in all sub folder(Toyota,Honda and BMW) and files ?

how can I intgreat cod to be user interface (buttun ,text box etc) and let user to enter find most X (10,20,30 etc) frequency word
and how to let user to writ parent file name to search in its container (files and folders)

this is code

# a look at the Tkinter Text widget

# use ctrl+c to copy, ctrl+x to cut selected text,

# ctrl+v to paste, and ctrl+/ to select all
import Tkinter as tk


def most_frequant_word():

      # count words in a text and show the first ten items
    # by decreasing frequency

    # sample text for testing

    import sys
    import string
    import re
    v1.set(text1.get(1.0, tk.END))
    text1.delete(1.0, tk.END)
    file = open ("arb.txt", "r")
    text = file.read ( )
    file.close ( )

    word_freq = {}

    word_list = text.split()

    for word in word_list:
        # word all lower case
        word = word.lower()
        # strip any trailing period or comma
        word = word.rstrip('.,/"-_;\[]()')
        # build the dictionary
        count = word_freq.get(word, 0)
        word_freq[word] = count + 1

    # create a list of (freq, word) tuples
    freq_list = [(freq, word) for word, freq in word_freq.items()]

    # sort the list by the first element in each tuple (default)
    freq_list.sort(reverse=True)

    for n, tup in enumerate(freq_list):
        # print the first ten items
        if n < 10:
            text1.insert(tk.INSERT, freq)
            text1.insert(tk.INSERT, word)
            text1.insert(tk.INSERT, "\n")
            freq, word = tup
            print freq, word
root = tk.Tk(className = " most_frequant_word")


# text entry field, width=width chars, height=lines text


text1 = tk.Text(root, width=50, height=20, bg='green')
text1.pack()
# function listed in command will be executed on button click
button1 = tk.Button(root, text='result', command=most_frequant_word)
button1.pack(pady=5)

# define a variable to hold the label text
v1 = tk.StringVar()
# label text will always be the textvariable's value
# width/height in char size
label1 = tk.Label(root, textvariable=v1, width=50, height=20)
label1.pack(pady=5)

# start cursor in text1.
text1.focus()
root.mainloop()

but unfortinatly when I wont to search in (not English text) for example (Arabic) file it will not read it probably it print text like

3ÇáäíÇÈÉ
28Ýí
11Úáì
11ÊÜÊÜãÜÉ
10ãä
10Úä
7Ãä
6ÈÓÈÈ
5ÎÈÑ
5ÇáãÓáãæä

sample file in attach

I use

        text1.insert(tk.INSERT, freq)
        text1.insert(tk.INSERT, word)
        text1.insert(tk.INSERT, "\n")

to inset to the text
pleas I need your help for this and previous one

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.