Lie Ryan wrote:
On 12/22/2009 11:25 PM, Steve Holden wrote:
>
> If you want to extract an index number from the first part of of a
given
> line use split( split_character, maximum_splits_to_do ) and then
angle
> brackets to reference the first part (index 0)...
>
>
a = "20 GOTO 10"
Steve Holden wrote:
> r0g wrote:
>> seafoid wrote:
>>> Hi Guys,
>>>
>>> When python reads in a file, can lines be referred to via an index?
>>>
>>> Example:
>>>
>>> for line in file:
>>> if line[0] == '0':
>>> a.write(line)
>>>
>>> This works, however, I am unsure if line[0] refers on
On 12/22/2009 11:25 PM, Steve Holden wrote:
>
> If you want to extract an index number from the first part of of a given
> line use split( split_character, maximum_splits_to_do ) and then angle
> brackets to reference the first part (index 0)...
>
>
a = "20 GOTO 10"
int( a.split('
r0g wrote:
> seafoid wrote:
>> Hi Guys,
>>
>> When python reads in a file, can lines be referred to via an index?
>>
>> Example:
>>
>> for line in file:
>> if line[0] == '0':
>> a.write(line)
>>
>> This works, however, I am unsure if line[0] refers only to the first line or
>> the fir
seafoid wrote:
> Hi Guys,
>
> When python reads in a file, can lines be referred to via an index?
>
> Example:
>
> for line in file:
> if line[0] == '0':
> a.write(line)
>
> This works, however, I am unsure if line[0] refers only to the first line or
> the first character in all l
ding them
> up or comparing them to the header attributes
>
> --
> Rory Campbell-Lange
> Director
> r...@campbell-lange.net
>
> Campbell-Lange Workshop
> www.campbell-lange.net
> 0207 6311 555
> 3 Tottenham Street London W1T 2AF
> Registered in E
o assign variables within a loop!
Is there an easy way to 'flatten' a nested list and assign the lists to
variables?
Thanks,
Seafoid.
--
View this message in context:
http://old.nabble.com/Line-indexing-in-Python-tp26845253p26849921.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
On 18/12/09, seafoid (fitzp...@tcd.ie) wrote:
> http://old.nabble.com/Parsing-file-format-to-ensure-file-meets-criteria-to26837682.html
Your specification is confusing. However I suggest you break it down
the code so that the steps in your programme are logical. Good luck.
# example psuedocode
he
On 18/12/09, seafoid (fitzp...@tcd.ie) wrote:
> Have you any suggestions how I may render this code undead or should I scrap
> it and create something new?
It might be easier for us to help you if you give us an example of your
input file and a clearer description of what you are trying to do with
r being a
> single letter that you know?
>
> Thanks in advance,
> Seafoid.
>
--
View this message in context:
http://old.nabble.com/Line-indexing-in-Python-tp26845253p26847598.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
On 12/19/2009 4:33 AM, seafoid wrote:
Thanks for that Lie.
I had to have a think about what you meant when you referred to control
going to a.write(line).
and if-elif-elif-... chain is executed sequentially and when a match is
found, the rest of the chain is skipped. Your code:
if line.sta
biologist :-(
Thanks,
Seafoid.
--
View this message in context:
http://old.nabble.com/Line-indexing-in-Python-tp26845253p26846854.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
On 12/19/2009 3:27 AM, seafoid wrote:
Thanks for that Richard and Steve.
I have another question.
What's the question?
fname = raw_input('Please enter the name of the file: ')
# create file objects
blah = open(fname, 'r')
a = open('rubbish', 'w')
for line in blah:
if line.startswith
this message in context:
http://old.nabble.com/Line-indexing-in-Python-tp26845253p26846049.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
ero, assign lines to lists.
Any suggestions?
Seafoid.
--
View this message in context:
http://old.nabble.com/Line-indexing-in-Python-tp26845253p26845949.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
seafoid wrote:
> Hi Guys,
>
> When python reads in a file, can lines be referred to via an index?
>
> Example:
>
> for line in file:
> if line[0] == '0':
> a.write(line)
>
> This works, however, I am unsure if line[0] refers only to the first line or
> the first character in all l
efers only to the first line or
> the first character in all lines.
>
> Is there an easy way to refer to a line with the first character being a
> single letter that you know?
>
> Thanks in advance,
> Seafoid.
> --
> View this message in
> context:http://old.nabble.co
y to refer to a line with the first character being a
single letter that you know?
Thanks in advance,
Seafoid.
--
View this message in context:
http://old.nabble.com/Line-indexing-in-Python-tp26845253p26845253.html
Sent from the Python - python-list mailing list archive at Nabble.com.
18 matches
Mail list logo