Re: Easier way to do this?

2017-10-05 Thread 20/20 Lab
On 10/04/2017 05:11 PM, Irv Kalb wrote: I'm assuming from your posts that you are not a student. If that is the case, look at my solution below. On Oct 4, 2017, at 9:42 AM, 20/20 Lab wrote: Looking for advice for what looks to me like clumsy code. I have a large csv (effectively garbage)

Re: Easier way to do this?

2017-10-05 Thread 20/20 Lab
On 10/04/2017 04:48 PM, Dennis Lee Bieber wrote: On Wed, 4 Oct 2017 09:42:18 -0700, 20/20 Lab declaimed the following: Well -- since your later post implies this is not some "homework assignment"... Looking for advice for what looks to me like clumsy code. EMP1 = [0,0] EMP2 = [0,0]

Re: Easier way to do this?

2017-10-05 Thread 20/20 Lab
On 10/05/2017 07:28 AM, Neil Cerutti wrote: On 2017-10-04, 20/20 Lab wrote: It's not quite a 'learning exercise', but I learn on my own if I treat it as such.  This is just to cut down a few hours of time for me every week filtering the file by hand for the office manager. That looks like a 30

Re: Easier way to do this?

2017-10-05 Thread Neil Cerutti
On 2017-10-04, 20/20 Lab wrote: > It's not quite a 'learning exercise', but I learn on my own if > I treat it as such.  This is just to cut down a few hours of > time for me every week filtering the file by hand for the > office manager. That looks like a 30-second job using a pivot table in Exce

Re: Easier way to do this?

2017-10-05 Thread Fabien
On 10/05/2017 12:00 AM, Thomas Jollans wrote: On 04/10/17 22:47, Fabien wrote: On 10/04/2017 10:11 PM, Thomas Jollans wrote: Be warned, pandas is part of the scientific python stack, which is immensely powerful and popular, but it does have a distinctive style that may appear cryptic if you're

Re: Easier way to do this?

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 11:11 AM, Irv Kalb wrote: > # If we have not seen this employee name before, add it to the dictionary > # like key value pair: '': [0, 0] > if not(name in employeeDataDict): > salesCountDict[name] = [0, 0] Python provides a "not in" operator, which i

Re: Easier way to do this?

2017-10-04 Thread Irv Kalb
I'm assuming from your posts that you are not a student. If that is the case, look at my solution below. > On Oct 4, 2017, at 9:42 AM, 20/20 Lab wrote: > > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump. I have to pull out sales >

Re: Easier way to do this?

2017-10-04 Thread Thomas Jollans
On 04/10/17 22:47, Fabien wrote: > On 10/04/2017 10:11 PM, Thomas Jollans wrote: >> Be warned, pandas is part of the scientific python stack, which is >> immensely powerful and popular, but it does have a distinctive style >> that may appear cryptic if you're used to the way the rest of the world >

Re: Easier way to do this?

2017-10-04 Thread 20/20 Lab
On 10/04/2017 01:55 PM, Ben Bacarisse wrote: 20/20 Lab writes: Looking for advice for what looks to me like clumsy code. I have a large csv (effectively garbage) dump.  I have to pull out sales information per employee and count them by price range. I've got my code working, but I'm thinkin

Re: Easier way to do this?

2017-10-04 Thread 20/20 Lab
On 10/04/2017 12:47 PM, breamore...@gmail.com wrote: On Wednesday, October 4, 2017 at 8:29:26 PM UTC+1, 20/20 Lab wrote: Any help / advice is appreciated, Matt Use the csv module https://docs.python.org/3/library/csv.html to read the file with a Counter https://docs.python.org/3/library/c

Re: Easier way to do this?

2017-10-04 Thread Ben Bacarisse
20/20 Lab writes: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump.  I have to pull out > sales information per employee and count them by price range. I've got > my code working, but I'm thinking there must be a more refined way of > d

Re: Easier way to do this?

2017-10-04 Thread Fabien
On 10/04/2017 10:11 PM, Thomas Jollans wrote: Be warned, pandas is part of the scientific python stack, which is immensely powerful and popular, but it does have a distinctive style that may appear cryptic if you're used to the way the rest of the world writes Python. Can you elaborate on this

Re: Easier way to do this?

2017-10-04 Thread Thomas Jollans
On 04/10/17 18:42, 20/20 Lab wrote: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump. I have to pull out > sales information per employee and count them by price range. I've got > my code working, but I'm thinking there must be a more re

Re: Easier way to do this?

2017-10-04 Thread breamoreboy
On Wednesday, October 4, 2017 at 8:29:26 PM UTC+1, 20/20 Lab wrote: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump.  I have to pull out sales > information per employee and count them by price range. I've got my code > working, but I

Easier way to do this?

2017-10-04 Thread 20/20 Lab
Looking for advice for what looks to me like clumsy code. I have a large csv (effectively garbage) dump.  I have to pull out sales information per employee and count them by price range. I've got my code working, but I'm thinking there must be a more refined way of doing this. ---snippet of w

Re: An easier way to do this? (spoiler if you're using pyschools for fun)

2010-11-10 Thread Matteo Landi
I agree with Peter: * iterate over the list directly * use %10 instead of string conversion + slice (*) use genexps Good luck, Matteo On Tue, Nov 9, 2010 at 8:18 PM, Terry Reedy wrote: > On 11/9/2010 2:00 PM, Matty Sarro wrote: > >> I'm working on one of the puzzles on pyschools.com >>

Re: An easier way to do this? (spoiler if you're using pyschools for fun)

2010-11-09 Thread Terry Reedy
On 11/9/2010 2:00 PM, Matty Sarro wrote: I'm working on one of the puzzles on pyschools.com , and am trying to figure out if I can make my solution a bit more elegant. Definitely def getSumOfLastDigit(numList): sumOfDigits=0 for i in range(0, len(numList)):

Re: An easier way to do this? (spoiler if you're using pyschools for fun)

2010-11-09 Thread Peter Otten
Matty Sarro wrote: > Hey everyone, > I'm working on one of the puzzles on pyschools.com, and am trying to > figure out if I can make my solution a bit more elegant. > > def getSumOfLastDigit(numList): > sumOfDigits=0 > for i in range(0, len(numList)): > num=str(numList.pop()) >

Re: An easier way to do this? (spoiler if you're using pyschools for fun)

2010-11-09 Thread Chris Rebert
On Tue, Nov 9, 2010 at 11:00 AM, Matty Sarro wrote: > Hey everyone, > I'm working on one of the puzzles on pyschools.com, and am trying to figure > out if I can make my solution a bit more elegant. > > def getSumOfLastDigit(numList): >     sumOfDigits=0 >     for i in range(0, len(numList)): >    

An easier way to do this? (spoiler if you're using pyschools for fun)

2010-11-09 Thread Matty Sarro
Hey everyone, I'm working on one of the puzzles on pyschools.com, and am trying to figure out if I can make my solution a bit more elegant. def getSumOfLastDigit(numList): sumOfDigits=0 for i in range(0, len(numList)): num=str(numList.pop()) sumOfDigits+=int(num[-1:]) r