Find most frequent phone number from given .txt file
<p>For example: 
me.txt (which conatains data as well as phone numbers)which has below info</p>

<pre><code>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

1.Phone number 1: (999) 999-3333
2.phone number 2: (888) 999 -2212
3.Phone number 3: (111) 222 - 2223
4.Phone number 4: (999)999-3333
5.Phone number 5: (888)222-2222
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

6.Phone number:  (999)999-3333
</code></pre>

<p>so the <strong>o/p</strong> should be : (999)999-3333 - 3 times </p>

<p>My try:</p>

<pre><code>txtFile = urllib.urlopen("http:// me.txt").readlines()
txtFile = "".join(char for char in txtFile if char.isdigit()) #removes everything that's not numeric.

phone_counter = {}
for phone in txtFile.split(" "): # split in every space.

    if len(phone) &gt; 0 :
        if phone not in phone_counter:  
            phone_counter[phone] = 1
        else:
            phone_counter[phone] += 1

for i,phone in  enumerate(sorted(phone_counter,key=phone_counter.get,reverse=True)[:-1]):
    print "%s: %s - %s"%(i+1,phone,phone_counter[phone])
</code></pre>

<p>This way I can't read numbers .Looking for <strong>python</strong> solution</p>

<p>You have several problems in the code.  I fixed the indentation error on the last line.  Next, your approach has to iterate through the characters of the file; <strong>readlines</strong> returns a list of strings, one per line.  Your second line necessarily returns null, because there's no entire line that will satisfy <strong>isdigit</strong>.</p>

<p>Also, note that stripping out all the non-digits would leave you with a string of 60 digits.  I don't think this is what you want.</p>

<p>I strongly recommend you start over and use incremental programming: write a couple of lines to retrieve the input.  Debug those.  Do not advance until those work.  <em>Then</em> you can write the processing you want for detecting phone numbers.</p>

<p>Thanks to the other answer, all you need do from here is to separate the file into phone numbers on separate lines.  Be careful: the phone numbers have embedded spaces.</p>

python