Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.04; 'subject:Python': 0.05; 'lines,': 0.05; 'be:': 0.09; 'formatted': 0.09; 'postgres': 0.09; 'record.': 0.09; 'sqlite': 0.09; 'cc:addr :python-list': 0.10; 'django': 0.10; 'aug': 0.13; 'files.': 0.13; 'file:"': 0.16; 'iterates': 0.16; 'message-id:@unknownmsgid': 0.16; 'row': 0.16; 'subject:loss': 0.16; "team's": 0.16; 'win,': 0.16; 'wrote:': 0.17; 'thanks,': 0.18; 'file.': 0.20; 'trying': 0.21; 'cc:2**0': 0.23; 'example': 0.23; 'project,': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'fit': 0.26; 'guess': 0.27; 'subject:/': 0.28; 'run': 0.28; 'record': 0.28; 'finds': 0.29; 'teams,': 0.29; 'url:mailman': 0.29; "i'm": 0.29; "we're": 0.30; 'saves': 0.30; 'up.': 0.31; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'received:209.85.160.46': 0.32; 'running': 0.32; 'url:listinfo': 0.32; 'handle': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'loss': 0.34; 'skip:k 20': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'next': 0.35; 'but': 0.36; 'url:org': 0.36; 'does': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'url:mail': 0.40; 'your': 0.60; 'lost': 0.60; 'first': 0.61; 'results': 0.65; 'total': 0.65; 'records.': 0.65; 'talking': 0.66; 'sports': 0.69; 'low': 0.83; 'confusing': 0.84; "it'd": 0.84; 'moves': 0.84; 'ohio': 0.84; "they'd": 0.84; 'subject:records': 0.91; 'outcome': 0.93; 'won': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=yHkwoOmOjQL28wqeSpYqpn2PVcijXDen+G1PKSDaJYw=; b=lDuPa2p40HOJCPX/zFymO3On/GyZeAU+ZfqFFskQjRyl/pvsG/Fd5S1khEwlyfYq1d nXQHpPcdjitN2DJITevqPGw+t+oA+E3BHq/2jHyIaToVp51DhpHkkmcLBI2hPRdQOKfP U7S9YrqVttezdnMlrA1aT+Qy0auUarQT5/VB+ttxdTSq1Vne2zY+MP3WVSoxFBzZwslr HWcDsOR9tmfBYliyCRi5YGx4u/58FQwluajOGdq0UjyUfsCruJMMcNJV2ftJXtSDCeK+ YkuLzW93dcbOnzHHEiHYxy4vAVhpYHrC7JC4PGAeg8yhVYLVB+Arx+L2nFZvXJ23m95/ bwww== References: <0C181E0E-47FA-439C-8320-AC60AB8859AF@gmail.com> From: Rodrick Brown In-Reply-To: <0C181E0E-47FA-439C-8320-AC60AB8859AF@gmail.com> Mime-Version: 1.0 (1.0) Date: Sat, 25 Aug 2012 22:32:22 -0400 Subject: Re: Computing win/loss records in Python To: Christopher McComas Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345948348 news.xs4all.nl 6864 [2001:888:2000:d::a6]:45245 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27895 On Aug 25, 2012, at 10:22 PM, Christopher McComas wrote: > Greetings, > > I have code that I run via Django that grabs the results from various spo= rts from formatted text files. The script iterates over every line in the f= ormatted text files, finds the team in the Postgres database updates their = w/l record depending on the outcome on that line, saves the team's row in t= he db, and then moves on to the next line in the file. > > I'm trying to get away from Django for this project, I want to run the fi= les, get the W/L results and output a formatted text file with the teams an= d their W/L records. What's confusing me I guess how to store the data/resu= lts as the wins and losses tally up. We're talking hundreds of teams, thous= ands of games, but a quick example would be: > > Marshall > Ohio State > Kentucky > Indiana > > Marshall,24,Ohio State,48, > Kentucky,14,Indiana,10, > Marshall,10,Indiana,7, > Ohio State,28,Kentucky,10 > > That's just a quick example, I can handle seperating the data in the line= s, figuring it all out, I just am unsure of how to keep a running total of = a team's record. I would do "for line in file:" then on the first line I se= e that Marshall lost so they would have 1, Ohio State won so they'd have 1 = win. It'd go to the next line Kentucky 1 win, Indiana 1 loss, then on the 3= rd line, Marshall got a win so they'd have 1 win, but it would have to reme= mber that loss from line 1... > > Does this make sense? Yes, use a RDBMS, SQLite may be the best fit for your use case its quick and has low overhead. > > Thanks, > -- > http://mail.python.org/mailman/listinfo/python-list