Jay Mutter III [EMAIL PROTECTED] wrote
Whether I attempt to just strip the string or attempt to
if line.endswith('No.\r'):
line = line.rstrip()
It doesn't work.
Can you try printing the string repr just before the test.
Or even the last 6 characters:
print repr(line[-6
-type=original
Jay Mutter III [EMAIL PROTECTED] wrote
inp = open('test.txt','r')
s = inp.readlines()
for line in s:
if line.endswith('No.'):
line = line.rstrip()
print line
BTW,
You do know that you can shorten that considerably?
With:
for line in open('test.txt
=original
Jay Mutter III [EMAIL PROTECTED] wrote
for line in s:
jay = patno.findall(line)
jay2 = .join(jay[0])
print jay2
and it prints fine up until line 111 which is a line that had
previously returned [ ] since a number didn't exist on that line and
then exits
I have the following that I am using to extract numbers' from a file
prompt1 = raw_input('What is the file from which you would like a
list of patent numbers? ')
p1 = open(prompt1,'rU')
s = p1.readlines()
prompt2 = raw_input('What is the name of the file to which you would
like to save
Ok after a minute of thought I did solve my second question by simply
changing my RE to
(r'(\d{1}[\s,.]+\d{3}[\s,.]+\d{3})')
but still haven't gotten he first one.
On Mar 31, 2007, at 1:39 PM, Jay Mutter III wrote:
I have the following that I am using to extract numbers' from a file
, if line ends with the abbreviation No.
I want to join the current line with next line.
Are lists immutable or can they be changed?
Thanks again
jay
On Mar 31, 2007, at 2:27 PM, Kent Johnson wrote:
Jay Mutter III wrote:
I have the following that I am using to extract numbers' from a file
: Jay Mutter III
Subject: [Tutor] parsing text
[...]
1.) when i do readlines and create a list and then print the list it
adds a blank line between every line of text
[...]
ideas?
Thanks again
jay
Well,
regarding your first question:
print string automatically breaks a line at the end
.','\n') in an attempt to put a CR in but
it just put the characters\n in the string.
ideas?
Thanks again
jay
Jay Mutter III wrote:
Thanks for the response
Actually the number of lines this returns is the same number of lines
given when i put it in a text editor (TextWrangler).
Luke had
On Mar 23, 2007, at 5:30 AM, Andre Engels wrote:
2007/3/22, Jay Mutter III [EMAIL PROTECTED]:
I wanted the following to check each line and if it ends in a right
parentheses then write the entire line to one file and if not then
write the line to anther.
It wrote all of the ) to one file
Andre;
Thanks again for the assistance.
I have corrected the splitlines error and it works ( well that part
of anyway) correctly now.
On Mar 23, 2007, at 5:30 AM, Andre Engels wrote:
2007/3/22, Jay Mutter III [EMAIL PROTECTED]:
I wanted the following to check each line and if it ends
/07, Kent Johnson [EMAIL PROTECTED] wrote:
Jay Mutter III wrote:
Why is it that when I run the following interactively
f = open('Patents-1920.txt')
line = f.readline()
while line:
print line,
line = f.readline()
f.close()
I get an error message
File stdin, line 4
f.close
Script i have to date is below and
Thanks to your help i can see some daylight but I still have a few
questions
1.) Are there better ways to write this?
2.) As it writes out the one group to the new file for companies it
is as if it leaves blank lines behind for if I don't have the elif len
Why is it that when I run the following interactively
f = open('Patents-1920.txt')
line = f.readline()
while line:
print line,
line = f.readline()
f.close()
I get an error message
File stdin, line 4
f.close()
^
SyntaxError: invalid syntax
but if i run it in a script there
I wanted the following to check each line and if it ends in a right
parentheses then write the entire line to one file and if not then
write the line to anther.
It wrote all of the ) to one file and the rest of the line (ie minus
the ) to the other file.
in_filename = raw_input('What is
Jay Mutter III jmutter at uakron.edu wrote
See example next:
A.-C. Manufacturing Company. (See Sebastian, A. A.,
and Capes, assignors.)
...
Aaron, Solomon E., Boston, Mass. Pliers. No. 1,329,155 ;
Jan. 27 ; v. 270 ; p. 554.
For instance, I would like to go to end of line and if last
I am using an intel iMac with OS -X 10.4.8.
It has Python 2.3.5.
My issue is that I have a lot of text ( about 500 pages at the
moment) that I need to parse so that I can eliminate info I don't
need, break the remainder into fields and put in a database/spreadsheet.
See example next:
A.-C.
16 matches
Mail list logo