Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'preferably': 0.05; 'subject:text': 0.05; 'nested': 0.07; 'subject:Picking': 0.07; 'alternatives': 0.09; 'arrays': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'stored': 0.12; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sift': 0.16; 'sqlite': 0.16; 'whitespace.': 0.16; 'wrote:': 0.18; 'library': 0.18; 'bit': 0.19; 'module': 0.19; 'split': 0.19; 'thoughts': 0.19; 'header:User-Agent:1': 0.23; 'simpler': 0.24; 'sort': 0.25; "i've": 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'database,': 0.30; 'originally': 0.30; "i'm": 0.30; 'getting': 0.31; 'lines': 0.31; 'bunch': 0.31; 'extract': 0.31; 'location,': 0.31; 'there.': 0.32; 'another': 0.32; 'text': 0.33; 'open': 0.33; 'moment': 0.34; 'there,': 0.34; 'info': 0.35; 'convert': 0.35; 'but': 0.35; 'i.e.': 0.36; 'reports': 0.37; 'list': 0.37; 'list.': 0.37; 'starting': 0.37; 'system,': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'how': 0.40; 'easy': 0.60; 'up,': 0.60; 'gone': 0.61; 'simple': 0.61; 'first': 0.61; 'back': 0.62; 'information': 0.63; 'such': 0.63; 'field': 0.63; 'charset:windows-1252': 0.65; 'iron': 0.68; 'results': 0.69; 'fields).': 0.84; 'pdf.': 0.84; 'pdfs': 0.84; 'russell': 0.84; 'so...': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Russell Owen Subject: Re: Picking apart a text line Date: Mon, 02 Mar 2015 12:25:34 -0800 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: d-128-208-13-159.dhcp4.washington.edu User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425327960 news.xs4all.nl 2888 [2001:888:2000:d::a6]:58384 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86784 On 2/26/15 7:53 PM, memilanuk wrote: > So... okay. I've got a bunch of PDFs of tournament reports that I want > to sift thru for information. Ended up using 'pdftotext -layout > file.pdf file.txt' to extract the text from the PDF. Still have a few > little glitches to iron out there, but I'm getting decent enough results > for the moment to move on. > ... > So back to the lines of text I have stored as strings in a list. I > think I want to convert that to a list of lists, i.e. split each line > up, store that info in another list and ditch the whitespace. Or would > I be better off using dicts? Originally I was thinking of how to > process each line and split it them up based on what information was > where - some sort of nested for/if mess. Now I'm starting to think that > the lines of text are pretty uniform in structure i.e. the same field is > always in the same location, and that list slicing might be the way to > go, if a bit tedious to set up initially...? > > Any thoughts or suggestions from people who've gone down this particular > path would be greatly appreciated. I think I have a general > idea/direction, but I'm open to other ideas if the path I'm on is just > blatantly wrong. It sounds to me as if the best way to handle all this is keep the information it in a database, preferably one available from the network and centrally managed, so whoever enters the information in the first place enters it there. But I admit that setting such a thing up requires some overhead. Simpler alternatives include using SQLite, a simple file-based database system, or numpy structured arrays (arrays with named fields). Python includes a standard library module for sqlite and numpy is easy to install. -- Russell