Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28018
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'see.': 0.07; 'strings.': 0.07; 'hallo,': 0.09; 'occurrences': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'target:': 0.09; 'index': 0.13; 'file,': 0.15; '"x"': 0.16; '(created': 0.16; '-1:': 0.16; 'libs': 0.16; 'occurences': 0.16; 'read:': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'repetition': 0.16; 'string': 0.17; 'wrote:': 0.17; 'char': 0.17; 'runs': 0.22; 'this:': 0.23; "i've": 0.23; 'script': 0.24; 'tried': 0.25; 'header:User- Agent:1': 0.26; 'see,': 0.27; 'header:X-Complaints-To:1': 0.28; 'code': 0.31; 'file': 0.32; 'print': 0.32; 'avoiding': 0.33; 'extract': 0.33; 'much.': 0.33; 'to:addr:python-list': 0.33; 'text': 0.34; 'wrong': 0.34; 'done': 0.34; 'locations': 0.35; 'text.': 0.35; 'subject:?': 0.35; 'there': 0.35; 'received:org': 0.36; 'thank': 0.36; 'passed': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'remove': 0.61; 'developed': 0.62; 'situation': 0.62; 'skip:n 10': 0.63; 'subject:read': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: What do I do to read html files on my pc? |
| Date | Tue, 28 Aug 2012 17:38:22 +0200 |
| Organization | None |
| References | <1c7cd833-b6ad-4a17-8ffe-a0ce20c8f400@googlegroups.com> <d356e2b9-62c4-4e5b-bc5a-63c3cb7a3685@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Gmane-NNTP-Posting-Host | p50849479.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3900.1346168282.4697.python-list@python.org> (permalink) |
| Lines | 76 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1346168282 news.xs4all.nl 6881 [2001:888:2000:d::a6]:51969 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28018 |
Show key headers only | View raw
mikcec82 wrote:
> Il giorno lunedì 27 agosto 2012 12:59:02 UTC+2, mikcec82 ha scritto:
>> Hallo,
>>
>>
>>
>> I have an html file on my pc and I want to read it to extract some text.
>>
>> Can you help on which libs I have to use and how can I do it?
>>
>>
>>
>> thank you so much.
>>
>>
>>
>> Michele
>
> Hi Oscar,
> I tried as you said and I've developed the code as you will see.
> But, when I have a such situation in an html file, in wich there is a
> repetition of a string (XX in this case):
> CODE Target: 0201
> CODE Read: XXXX
> CODE CHECK : NOT PASSED
> TEXT Target: 13
> TEXT Read: XX
> TEXT CHECK : NOT PASSED
> CHAR Target: AA
> CHAR Read: XX
> CHAR CHECK : NOT PASSED
>
> With this code (created starting from yours)
>
> index = nomefile.find('XXXX')
> print 'XXXX_ found at location', index
>
> index2 = nomefile.find('XX')
> print 'XX_ found at location', index2
>
> found = nomefile.find('XX')
> while found > -1:
> print "XX found at location", found
> found = nomefile.find('XX', found+1)
>
> I have an answer like this:
>
> XXXX_ found at location 51315
> XX_ found at location 51315
> XX found at location 51315
> XX found at location 51316
> XX found at location 51317
> XX found at location 52321
> XX found at location 53328
>
> I have done it to find all occurences of 'XXXX' and 'XX' strings. But, as
> you can see, the script find the occurrences of XX also at locations
> 51315, 51316 , 51317 corresponding to string XXXX.
>
> Is there a way to search all occurences of XX avoiding XXXX location?
Remove the wrong positives afterwards:
start = nomefile.find("XX")
while start != -1:
if nomefile[start:start+4] == "XXXX":
start += 4
else:
print "XX found at location", start
start += 3
start = nomefile.find("XX", start)
By the way, what do you want to do if there are runs of "X" with repeats
other than 2 or 4?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-27 03:59 -0700
Re: What do I do to read html files on my pc? Chris Angelico <rosuav@gmail.com> - 2012-08-27 21:58 +1000
Re: What do I do to read html files on my pc? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-27 13:05 +0100
Re: What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-27 06:51 -0700
Re: What do I do to read html files on my pc? Joel Goldstick <joel.goldstick@gmail.com> - 2012-08-27 10:21 -0400
Re: What do I do to read html files on my pc? Chris Angelico <rosuav@gmail.com> - 2012-08-28 00:41 +1000
Re: What do I do to read html files on my pc? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-27 18:57 +0200
Re: What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-28 03:09 -0700
Re: What do I do to read html files on my pc? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-08-28 13:31 +0100
Re: What do I do to read html files on my pc? Peter Otten <__peter__@web.de> - 2012-08-28 17:38 +0200
Re: What do I do to read html files on my pc? mikcec82 <michele.cecere@gmail.com> - 2012-08-29 03:22 -0700
Re: What do I do to read html files on my pc? Umesh Sharma <usharma01@gmail.com> - 2012-08-29 05:00 -0700
csiph-web