On Monday, 24 February 2014 11:48:23 UTC, sffj...@gmail.com wrote:
> split_points = [2, 4, 5]
Change this to `split_points = [3, 5]` for your requirements
--Simon Kennedy
--
https://mail.python.org/mailman/listinfo/python-list
On Thursday, 20 February 2014 16:22:00 UTC, kxjakkk wrote:
> Let's say I have a sample file like this:
> Name1 2 34 5 6 78
>
> name1099-66-7871 A-FY10067815
s = 4
e = 7
with f = file('path_to_file) as fp:
for line in f:
if line.startswith(name):
avg = sum(map(int, filter(ambda x : len(x) > 0,
s.split(' '))[s : e])) / (e - s)
On 20.02.2014 17:22, kxjakkk wrote:
Let
On Feb 20, 2014, at 8:54 AM, Dave Angel wrote:
> kxjakkk Wrote in message:
>> Let's say I have a sample file like this:
>>
>> Name1 2 34 5 6 78
>>
>> name1099-66-7871 A-F
On 2014-02-20 18:16, kjaku...@gmail.com wrote:
What I've got is
def stu_scores():
lines = []
with open("file.txt") as f:
lines.extend(f.readlines())
return ("".join(lines[11:]))
scores = stu_scores()
for line in scores:
fields = line.split()
name = fields[0]
kjaku...@gmail.com wrote:
> Error comes up saying "IndexError: list index out of range."
OK, then the 12th line starts with a whitespace char. Add more print
statements to see the problem:
> scores = stu_scores()
print scores
> for line in scores:
print repr(line)
> fields = line.
On Thu, Feb 20, 2014 at 7:16 PM, wrote:
> What I've got is
> def stu_scores():
> lines = []
> with open("file.txt") as f:
> lines.extend(f.readlines())
> return ("".join(lines[11:]))
This returns a string, not a list. Moreover, lines.extend() is
useless. Replace this with:
scores = stu_scores()
for line in scores:
fields = line.split()
name = fields[0]
print (fields)
Error comes up saying "IndexError: list index out of range."
--
https://mail.python.org/mailman/listinfo/python-list
On Feb 20, 2014 1:20 PM, wrote:
>
> What I've got is
> def stu_scores():
> lines = []
> with open("file.txt") as f:
> lines.extend(f.readlines())
> return ("".join(lines[11:]))
>
> scores = stu_scores()
> for line in scores:
> fields = line.split()
> name = fields[0]
Pr
What I've got is
def stu_scores():
lines = []
with open("file.txt") as f:
lines.extend(f.readlines())
return ("".join(lines[11:]))
scores = stu_scores()
for line in scores:
fields = line.split()
name = fields[0]
sum1 = int(fields[4]) + int(fields[5]) + int(fields[6
In <882091da-a499-477e-8f50-c5bdde7cd...@googlegroups.com> kxjakkk
writes:
> Let's say I have a sample file like this:
> Name1 2 34 5 6 78
>
> name1099-66-7871 A-FY1
On Feb 20, 2014 11:25 AM, "kxjakkk" wrote:
>
> Let's say I have a sample file like this:
>
> Name1 2 34 5 6 78
>
> name1099-66-7871 A-FY10067815998
> na
Let's say I have a sample file like this:
Name1 2 34 5 6 78
name1099-66-7871 A-FY10067815998
name2999-88-7766 A-FN99 1009691
13 matches
Mail list logo