Re: [Tutor] Parsing and collecting keywords from a webpage

2018-06-21 Thread Peter Otten
Daniel Bosah wrote: > new_list = [x.encode('latin-1') for x in sorted(paul)] I don't see why you would need bytes > search = "(" + b"|".join(new_list).decode() + ")" + "" #re.complie needs when your next step is to decode it. I'm not sure why it even works as the default encoding is usually

Re: [Tutor] Parsing and collecting keywords from a webpage

2018-06-21 Thread Alan Gauld via Tutor
On 20/06/18 20:32, Daniel Bosah wrote: > reg = pattern.findall(str(soup)) > > for i in reg: > if i in reg and paul: # this loop checks to see if elements are in > both the regexed parsed list and the list. No it doesn't. It checks if i is in reg and if paul is non empty - which it alwa

Re: [Tutor] Parsing and collecting keywords from a webpage

2018-06-20 Thread Alan Gauld via Tutor
On 20/06/18 20:32, Daniel Bosah wrote: > # coding: latin-1 > from bs4 import BeautifulSoup > from urllib.request import urlopen > import re > > #new point to add... make rest of function then compare a list of monuments > notaries ( such as blvd, road, street, etc.) to a list of words containing >

[Tutor] Parsing and collecting keywords from a webpage

2018-06-20 Thread Daniel Bosah
# coding: latin-1 from bs4 import BeautifulSoup from urllib.request import urlopen import re #new point to add... make rest of function then compare a list of monuments notaries ( such as blvd, road, street, etc.) to a list of words containing them. if contained, pass into new set ( ref notes in c

Re: [Tutor] Parsing a String

2016-11-25 Thread Bryon Adams
On 11/25/2016 05:26 PM, Bryon Adams wrote: Hello, I have written a script that pulls certain bits of information out of a Cisco router's 'show version' command. The output is given in the assignment and it does work on several different routers (I tested 3 different models from work). What I

[Tutor] Parsing a String

2016-11-25 Thread Bryon Adams
Hello, I have written a script that pulls certain bits of information out of a Cisco router's 'show version' command. The output is given in the assignment and it does work on several different routers (I tested 3 different models from work). What I did seems a bit messy to me though, woul

Re: [Tutor] parsing xml as lines

2015-11-04 Thread Peter Otten
richard kappler wrote: > I have an xml file that get's written to as events occur. Each event > writes a new 'line' of xml to the file, in a specific format, eg: > sometthing like this: > > http://www.w3.org/2001/XMLSchema-instance"; > xsi:noNamespaceSchemaLocation="Logging.xsd" version="1.0"> h

[Tutor] parsing xml as lines

2015-11-04 Thread richard kappler
I have an xml file that get's written to as events occur. Each event writes a new 'line' of xml to the file, in a specific format, eg: sometthing like this: http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="Logging.xsd" version="1.0">somestuff and each 'line' has that sam

Re: [Tutor] Parsing/Crawling test College Class Site.

2015-06-01 Thread Mark Lawrence
On 02/06/2015 00:06, bruce wrote: Hi. I'm creating a test py app to do a quick crawl of a couple of pages of a psoft class schedule site. Before I start asking questions/pasting/posting code... I wanted to know if this is the kind of thing that can/should be here.. The real issues I'm facing are

Re: [Tutor] Parsing/Crawling test College Class Site.

2015-06-01 Thread Alan Gauld
On 02/06/15 00:06, bruce wrote: Hi. I'm creating a test py app to do a quick crawl of a couple of pages of a psoft class schedule site. Before I start asking questions/pasting/posting code... I wanted to know if this is the kind of thing that can/should be here.. Probably. we are targeted at b

[Tutor] Parsing/Crawling test College Class Site.

2015-06-01 Thread bruce
Hi. I'm creating a test py app to do a quick crawl of a couple of pages of a psoft class schedule site. Before I start asking questions/pasting/posting code... I wanted to know if this is the kind of thing that can/should be here.. The real issues I'm facing aren't so much pythonic as much as prob

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 23:22, Martin A. Brown wrote: arr = json.loads('{ "name": "Joe", "address": "111 Street" }') arr.get('address') Here are some notes about why: # -- You will notice I used a variable called 'arr' instead of #array, because there is a module called array, and I may

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Steven D'Aprano
On Thu, Dec 11, 2014 at 02:25:53PM -0600, Galen Seilis wrote: > I would appreciate assitance understanding why this doesn't work, and how I > can get up-and-running with inputing JSON code into Python. Did you try reading the Fine Manual? It has many examples! For Python 2: https://docs.python.o

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Ben Finney
Alan Gauld writes: > On 11/12/14 23:15, Ben Finney wrote: > > >> *array = json.load( { "name": "Joe", "address": "111 Street" } )* > > > > You are passing a Python dict value to the function. JSON is a > > serialisation format, and the input to ‘json.load’ must be a text > > string. > > Nope, its

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Martin A. Brown
Hello there, To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, in File "C:\Python27\lib

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 23:15, Ben Finney wrote: *array = json.load( { "name": "Joe", "address": "111 Street" } )* You are passing a Python dict value to the function. JSON is a serialisation format, and the input to ‘json.load’ must be a text string. Nope, its a file-like object. The input to loads()

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 20:25, Galen Seilis wrote: To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, i

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Ben Finney
Galen Seilis writes: > I am having difficulty interacting with JSON. The example below if a > typical input and output: Thank you for presenting a simple example and the resulting output. Unfortunately, your mail client has mangled it, inserting asterisks making syntax errors, and wrapping line

[Tutor] Parsing JSON with Python

2014-12-11 Thread Galen Seilis
To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, in File "C:\Python27\lib\json\__init__.py

Re: [Tutor] Parsing txt file

2014-08-20 Thread Cameron Simpson
On 20Aug2014 16:35, Dima Kulik wrote: Hi to all. I have a problem with parsing file. I have txt file exported from AD and it has such structure: DistinguishedName : CN=*** ,OU=*** ,OU=*** ,DC=*** ,DC=***,DC=*** GroupCategory : Distribution GroupScope    : Universal Name  : *

Re: [Tutor] Parsing txt file

2014-08-20 Thread Danny Yoo
> i need to export to file all stings which start from "Name" > > I've tried to make little parser: > > keywords = ['Name', 'Name:'] > input_file=open("Mail_Groups.txt","r").readlines() > output_file=open("Out.txt","w") > for line in input_file: > for word in line.split(): > if word in

Re: [Tutor] Parsing txt file

2014-08-20 Thread Dave Angel
Dima Kulik Wrote in message: Please post in text mode. The html mode you used can cause multiple problems. Please specify your Python version and os version in any new thread.It sometimes makes a big difference in the solution. Your primary problem is that you don't close the files. But yo

[Tutor] Parsing txt file

2014-08-20 Thread Dima Kulik
Hi to all. I have a problem with parsing file. I have txt file exported from AD and it has such structure: DistinguishedName : CN=*** ,OU=*** ,OU=*** ,DC=*** ,DC=***,DC=*** GroupCategory : Distribution GroupScope    : Universal Name  : ObjectClass   : group ObjectGUI

Re: [Tutor] Parsing multiple lines from text file using regex

2013-10-27 Thread Peter Otten
Marc wrote: > Hi, > I am having an issue with something that would seem have an easy solution, > which escapes me. I have configuration files that I would like to parse. > The data I am having issue with is a multi-line attribute that has the > following structure: > > banner > Banner text > B

[Tutor] Parsing multiple lines from text file using regex

2013-10-27 Thread Marc
Hi, I am having an issue with something that would seem have an easy solution, which escapes me. I have configuration files that I would like to parse. The data I am having issue with is a multi-line attribute that has the following structure: banner Banner text Banner text Banner text ... Th

Re: [Tutor] Parsing Rhino Sightings - Python

2013-10-06 Thread bob gailer
On 10/6/2013 12:11 PM, Mason Majors wrote: Dear Bob, I just came across your email address on the following website: https://mail.python.org/pipermail//tutor/2011-November/087044.html I was wondering, if you were able to provide any help and slove this Pythn coding problem, as I am working on

Re: [Tutor] Parsing and evaluating user input

2013-01-09 Thread Oscar Benjamin
On 9 January 2013 11:20, Timo wrote: > I'm having trouble finding a safe way to parse and evaluate user input in my > program. > > In my app, I'm using a calculation like this: > (a / b) * 100 > The user should be able to override this and their preference is stored in a > configuration file for

[Tutor] Parsing and evaluating user input

2013-01-09 Thread Timo
I'm having trouble finding a safe way to parse and evaluate user input in my program. In my app, I'm using a calculation like this: (a / b) * 100 The user should be able to override this and their preference is stored in a configuration file for later use. So I now have a string with the use

Re: [Tutor] Parsing a multi-line/record text file

2012-11-13 Thread wolfrage8...@gmail.com
On Sun, Nov 11, 2012 at 6:01 AM, Marc wrote: > ** > > Hello, > > I am trying to parse a text file with a structure that looks like: > > [record: Some text about the record] > > Attribute 1 = Attribute 1 text > > Attribute 3 = Attribute 3 text > > Attribute 4 = Attribute 4

Re: [Tutor] Parsing a multi-line/record text file

2012-11-10 Thread Dave Angel
On 11/11/2012 12:01 AM, Marc wrote: > Hello, > > I am trying to parse a text file with a structure that looks like: > > [record: Some text about the record] So the record delimiter starts with a left bracket, in first column? And all lines within the record are indented? Use this fact. >

[Tutor] Parsing a multi-line/record text file

2012-11-10 Thread Marc
Hello, I am trying to parse a text file with a structure that looks like: [record: Some text about the record] Attribute 1 = Attribute 1 text Attribute 3 = Attribute 3 text Attribute 4 = Attribute 4 text Attribute 7 = Attribute 7 text [record: Some text about the

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Steven D'Aprano
Spyros Charonis wrote: On Wed, May 30, 2012 at 8:16 AM, Steven D'Aprano wrote: [...] There is little as painful as a program which prints "An error occurred" and then *keeps working*. What does this mean? Can I trust that the program's final result is correct? How can it be correct if an error

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Spyros Charonis
On Wed, May 30, 2012 at 8:16 AM, Steven D'Aprano wrote: > On Wed, May 30, 2012 at 07:00:30AM +0100, Spyros Charonis wrote: > > FINAL SOLUTION: > > Not quite. You are making the mistake of many newbies to treat Python > exceptions as a problem to be covered up and hidden, instead of as a > useful s

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-30 Thread Steven D'Aprano
On Wed, May 30, 2012 at 07:00:30AM +0100, Spyros Charonis wrote: > FINAL SOLUTION: Not quite. You are making the mistake of many newbies to treat Python exceptions as a problem to be covered up and hidden, instead of as a useful source of information. To quote Chris Smith: "I find it amusi

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-29 Thread Spyros Charonis
FINAL SOLUTION: ### LOOP OVER DIRECTORY location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels' zdata = [] for filename in os.listdir(location): filename = os.path.join(location, filename) try: zdata.extend(extract_zcoord(filename)) except NameError: print "No such file!" except SyntaxEr

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-29 Thread Steven D'Aprano
Steven D'Aprano wrote: location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels/' zdata = [] for filename in os.listdir(location): zdata.extend(get_zcoords(filename)) Hah, that can't work. listdir returns the name of the file, but not the file's path, which means that Python will

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-27 Thread Steven D'Aprano
Spyros Charonis wrote: The problem is that the list (z_coords1) returns as an empty list. I know the code works (too large to post here) So you want us to diagnose a problem in code that we can't see? I admire your confidence in our powers of deduction. [...] Short of some intricacy with

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-27 Thread Spyros Charonis
Returning to this original problem, I have modified my program from a single long procedure to 3 functions which do the following: serialize_pipeline_model(f): takes as input a file, reads it and parses coordinate values (numerical entries in the file) into a list write_to_binary(): writes the ge

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-19 Thread Alan Gauld
On 19/05/12 12:42, Spyros Charonis wrote: I have tried the following two snippets which both results in the same error import os, glob os.chdir('users/spyros/desktop/3NY8MODELSHUMAN/') homology_models = glob.glob('*.pdb') for i in range(len(homology_models)): python serialize_PIPELINE_mo

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-19 Thread Spyros Charonis
I have tried the following two snippets which both results in the same error import os, glob os.chdir('users/spyros/desktop/3NY8MODELSHUMAN/') homology_models = glob.glob('*.pdb') for i in range(len(homology_models)): python serialize_PIPELINE_models.py homology_models[i] import os, sys path = "/

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Steven D'Aprano
Spyros Charonis wrote: Dear Python community, I have a set of ~500 files which I would like to run a script on. My script extracts certain information and generates several lists with items I need. For one of these lists, I need to combine the information from all 500 files into one super-list.

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Alan Gauld
On 18/05/12 19:23, Spyros Charonis wrote: Dear Python community, I have a set of ~500 files which I would like to run a script on. > ...Is there a way in which I can iteratively execute my script > over all 500 files Yes. You could use os.walk() or the glob module depending on whether the file

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Prasad, Ramit
>I have a set of ~500 files which I would like to run a script on. My script >extracts certain information and >generates several lists with items I need. For one of these lists, I need to >combine the information from all >500 files into one super-list. Is there a way in which I can iterativel

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Joel Goldstick
On Fri, May 18, 2012 at 2:23 PM, Spyros Charonis wrote: > Dear Python community, > > I have a set of ~500 files which I would like to run a script on. My script > extracts certain information and > generates several lists with items I need. For one of these lists, I need to > combine the informati

Re: [Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Sarma Tangirala
On 18 May 2012 23:53, Spyros Charonis wrote: > Dear Python community, > > I have a set of ~500 files which I would like to run a script on. My > script extracts certain information and > generates several lists with items I need. For one of these lists, I need > to combine the information from al

[Tutor] Parsing data from a set of files iteratively

2012-05-18 Thread Spyros Charonis
Dear Python community, I have a set of ~500 files which I would like to run a script on. My script extracts certain information and generates several lists with items I need. For one of these lists, I need to combine the information from all 500 files into one super-list. Is there a way in which I

Re: [Tutor] Parsing

2011-11-27 Thread Alan Gauld
On 27/11/11 20:45, Deanna Wilson wrote: Project 4: Parsing rhinoceros sightings OK, You've told us this is homework, and you appear to have made some start but we need some more information. Can you program in any other language other than Python? Which version of Python are you using

Re: [Tutor] Parsing

2011-11-27 Thread Andreas Perstinger
[Please reply to the list. Your indentation also got lost during the mail delivery.] On 2011-11-27 23:21, Deanna Wilson wrote: Yes it is homework, but not from Penn state. It is a Geog690 class. I'm having difficulties with determining where the rhino is referenced in the split line, determinin

Re: [Tutor] Parsing

2011-11-27 Thread Andreas Perstinger
On 2011-11-27 21:45, Deanna Wilson wrote: Project 4: Parsing rhinoceros sightings Please confirm that this is homework. At least I've found this site: https://www.e-education.psu.edu/geog485/node/144 [snip] sample of my code: What are your problems? I've skimmed your sample and found a nu

Re: [Tutor] Parsing

2011-11-27 Thread bob gailer
Welcome to the Tutor List. We are a few volunteers who enjoy tutoring folk on specific Python learning issues. We like posts that are in plain text rather than HTML. Please post plain text in future. Also your code has a blank line between every LOC, Please remove these in future posts I f

[Tutor] Parsing

2011-11-27 Thread Deanna Wilson
Project 4: Parsing rhinoceros sightings In this project, I’m working for a wildlife conservation group that is tracking rhinos in the African savannah. My field workers' software resources and GIS expertise are limited, but you have managed to obtain an Excel spreadsheet

Re: [Tutor] Parsing /etc/passwd

2011-10-12 Thread Peter Otten
Hugo Arts wrote: >> f = open('/etc/passwd', 'r') > users = f.readlines() > for user in users: ... You can iterate over the file directly: for user in f: ... The version using readlines() reads the whole file into a list of lines where the alternative just has to remember the current

Re: [Tutor] Parsing /etc/passwd

2011-10-12 Thread Gerhardus Geldenhuis
Fantastic, Thanks Hugo that makes 100% sense now! Testing both regex for including / and doing split and when done throwing both away and using the default module. Regards On Wed, Oct 12, 2011 at 2:49 PM, Hugo Arts wrote: > On Wed, Oct 12, 2011 at 3:41 PM, Gerhardus Geldenhuis > wrote: > > Hi

Re: [Tutor] Parsing /etc/passwd

2011-10-12 Thread Hugo Arts
On Wed, Oct 12, 2011 at 3:41 PM, Gerhardus Geldenhuis wrote: > Hi > I wrote the following code: >   f = open('/etc/passwd', 'r') >   users = f.read() >   userelements = re.findall(r'(\w+):(\w+):(\w+):(\w+):(\w+):(\w+):(\w+)', > users) >   print userelements >   for user in userelements: >     (use

[Tutor] Parsing /etc/passwd

2011-10-12 Thread Gerhardus Geldenhuis
Hi I wrote the following code: f = open('/etc/passwd', 'r') users = f.read() userelements = re.findall(r'(\w+):(\w+):(\w+):(\w+):(\w+):(\w+):(\w+)', users) print userelements for user in userelements: (username, encrypwd, uid, gid, gecos, homedir, usershell) = user # unpack the tupl

Re: [Tutor] Parsing an XML document using ElementTree

2011-06-10 Thread Sithembewena Lloyd Dube
Hi Stefan, Thanks for the code review :) Only just noticed this. On Wed, May 25, 2011 at 3:10 PM, Stefan Behnel wrote: > Sithembewena Lloyd Dube, 25.05.2011 14:40: > > Thanks for all your suggestions. I read up on gzip and urllib and also >> learned in the process that I could use urllib2 as i

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-25 Thread Stefan Behnel
Sithembewena Lloyd Dube, 25.05.2011 14:40: Thanks for all your suggestions. I read up on gzip and urllib and also learned in the process that I could use urllib2 as its the latest form of that library. Herewith my solution: I don't know how elegant it is, but it works just fine. def get_contest

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-25 Thread Sithembewena Lloyd Dube
Hi Everyone, Thanks for all your suggestions. I read up on gzip and urllib and also learned in the process that I could use urllib2 as its the latest form of that library. Herewith my solution: I don't know how elegant it is, but it works just fine. def get_contests(): url = ' http://xml.ma

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Stefan Behnel
Sithembewena Lloyd Dube, 24.05.2011 11:59: I am trying to parse an XML feed and display the text of each child node without any success. My code in the python shell is as follows: >>> import urllib >>> from xml.etree import ElementTree as ET >>> content = urllib.urlopen(' http://xml.matchbook.c

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Alan Gauld
"Sithembewena Lloyd Dube" wrote And now, to iterate through its child nodes and print out the text of each node: for node in xml_content.getiterator('contest'): ...name = node.attrib.get('text') ...print name ... Nothing is printed, i = 0 for node in xml_content.geti

[Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Sithembewena Lloyd Dube
Hi Everyone, I am trying to parse an XML feed and display the text of each child node without any success. My code in the python shell is as follows: >>>import urllib >>>from xml.etree import ElementTree as ET >>>content = urllib.urlopen(' http://xml.matchbook.com/xmlfeed/feed?sport-id=&vendor=T

Re: [Tutor] Parsing data from a csv file

2011-03-24 Thread Joel Goldstick
On Thu, Mar 24, 2011 at 8:34 AM, louis leichtnam wrote: > Hello, > > I am to extract a csv file from the web and parse it in python and after > that make it into an html page. > > I want to get the data out of the csv file, get rid of the "," and make it > readable. > > Questions: > I would like t

[Tutor] Parsing data from a csv file

2011-03-24 Thread louis leichtnam
Hello, I am to extract a csv file from the web and parse it in python and after that make it into an html page. I want to get the data out of the csv file, get rid of the "," and make it readable. Questions: I would like to be able to print the line I want but I don't know how to do it. I would

Re: [Tutor] Parsing RSS Feeds

2010-08-15 Thread Nitin Das
http://www.feedparser.org/ --nitin On Mon, Aug 16, 2010 at 3:50 AM, aug dawg wrote: > Hey all, > > Does anyone know of any modules to help my program parse RSS feeds? > > Thanks! > > ___ > Tutor maillist - Tutor@python.or

Re: [Tutor] Parsing RSS Feeds

2010-08-15 Thread Steven D'Aprano
On Mon, 16 Aug 2010 08:20:15 am aug dawg wrote: > Hey all, > > Does anyone know of any modules to help my program parse RSS feeds? Yes, many people know of modules to parse RSS feeds. If you google for "Python RSS feed" you will find them. -- Steven D'Aprano __

[Tutor] Parsing RSS Feeds

2010-08-15 Thread aug dawg
Hey all, Does anyone know of any modules to help my program parse RSS feeds? Thanks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Parsing through decorators program

2010-07-15 Thread Mary Morris
So my new internship asked me to write a program that would parse through all of our source code on an svn server, find all the decorators and print them. I found all of the decorators by finding the '@' symbol. What I still have to do is write something that will make the computer print all of th

[Tutor] parsing pyc files

2010-03-23 Thread prasad rao
Hi . If you want to see what is in a pyc file,just type od pycfile at bash command prompt. You can see only rows of numbers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tu

Re: [Tutor] parsing pyc files

2010-03-23 Thread Steven D'Aprano
On Tue, 23 Mar 2010 12:16:03 pm Jojo Mwebaze wrote: > Hello Tutor > > I have two problems, any help will be highly appreciated. > > How is possible to trace the all method calls, object instantiations, > variables used in running an experiment dynamically, without putting > print - or log statemen

Re: [Tutor] parsing pyc files

2010-03-23 Thread Steven D'Aprano
On Tue, 23 Mar 2010 10:01:11 pm Jojo Mwebaze wrote: > Researchers at our university are allowed to checkout code from CVS, > make modifications, change variables/parameters and run experiments.. > After experiments are run, results are published. (However we don't > allow them to commit the changes

Re: [Tutor] parsing pyc files

2010-03-23 Thread Jojo Mwebaze
Researchers at our university are allowed to checkout code from CVS, make modifications, change variables/parameters and run experiments.. After experiments are run, results are published. (However we don't allow them to commit the changes, till changes are approved) take an example, two researche

Re: [Tutor] parsing pyc files

2010-03-23 Thread Alan Gauld
"Jojo Mwebaze" wrote How is possible to trace the all method calls, object instantiations, variables used in running an experiment dynamically, without putting print - or log statements in my code? - some sort of provenance! There are several debuggers for Python including the pdb module

[Tutor] parsing pyc files

2010-03-22 Thread Jojo Mwebaze
Hello Tutor I have two problems, any help will be highly appreciated. How is possible to trace the all method calls, object instantiations, variables used in running an experiment dynamically, without putting print - or log statements in my code? - some sort of provenance! I would like to crea

Re: [Tutor] parsing a "chunked" text file

2010-03-19 Thread Karim Liateni
Hello, Thanks both of you for these useful information. Regards Karim Hugo Arts wrote: On Thu, Mar 18, 2010 at 12:54 PM, Stefan Behnel wrote: Karim Liateni, 04.03.2010 01:23: Yes, a *big* difference in the true sense of the word. Your code (assuming you meant to write "... for line in ..

Re: [Tutor] parsing a "chunked" text file

2010-03-18 Thread Hugo Arts
On Thu, Mar 18, 2010 at 12:54 PM, Stefan Behnel wrote: > Karim Liateni, 04.03.2010 01:23: > > Yes, a *big* difference in the true sense of the word. Your code (assuming > you meant to write "... for line in ..." ) evaluates the entire list > comprehension before returning from the call. Steven's c

Re: [Tutor] parsing a "chunked" text file

2010-03-18 Thread Stefan Behnel
Karim Liateni, 04.03.2010 01:23: Steven D'Aprano wrote: def skip_blanks(lines): """Remove leading and trailing whitespace, ignore blank lines.""" for line in lines: line = line.strip() if line: yield line Is there a big difference to write your first functions as below because I am not familia

Re: [Tutor] parsing a "chunked" text file

2010-03-03 Thread Karim Liateni
Hello Steven, Is there a big difference to write your first functions as below because I am not familiar with yield keyword? def skip_blanks(lines): """Remove leading and trailing whitespace, ignore blank lines.""" return [line.strip() in lines if line.strip()] I tried to write as wel

Re: [Tutor] parsing a "chunked" text file

2010-03-02 Thread Steven D'Aprano
On Tue, 2 Mar 2010 05:22:43 pm Andrew Fithian wrote: > Hi tutor, > > I have a large text file that has chunks of data like this: > > headerA n1 > line 1 > line 2 > ... > line n1 > headerB n2 > line 1 > line 2 > ... > line n2 > > Where each chunk is a header and the lines that follow it (up to the >

Re: [Tutor] parsing a "chunked" text file

2010-03-02 Thread spir
On Mon, 1 Mar 2010 22:22:43 -0800 Andrew Fithian wrote: > Hi tutor, > > I have a large text file that has chunks of data like this: > > headerA n1 > line 1 > line 2 > ... > line n1 > headerB n2 > line 1 > line 2 > ... > line n2 > > Where each chunk is a header and the lines that follow it (up

Re: [Tutor] parsing a "chunked" text file

2010-03-02 Thread Christian Witts
Andrew Fithian wrote: Hi tutor, I have a large text file that has chunks of data like this: headerA n1 line 1 line 2 ... line n1 headerB n2 line 1 line 2 ... line n2 Where each chunk is a header and the lines that follow it (up to the next header). A header has the number of lines in the chun

[Tutor] parsing a "chunked" text file

2010-03-02 Thread Andrew Fithian
Hi tutor, I have a large text file that has chunks of data like this: headerA n1 line 1 line 2 ... line n1 headerB n2 line 1 line 2 ... line n2 Where each chunk is a header and the lines that follow it (up to the next header). A header has the number of lines in the chunk as its second field. I

Re: [Tutor] parsing Spreadsheet document

2009-12-10 Thread Emile van Sebille
On 12/9/2009 10:05 PM Christopher Spears said... I want to fill a database with the contents of a spreadsheet. The spreadsheet was created by OpenOffice and is a .sxc document. What is the best way to do this? I think the best approach is to save the spreadsheet as a .csv document and then

Re: [Tutor] parsing Spreadsheet document

2009-12-10 Thread Alan Gauld
"Christopher Spears" wrote I want to fill a database with the contents of a spreadsheet. The spreadsheet was created by OpenOffice and is a .sxc document. I think the best approach is to save the spreadsheet as a .csv document If you have control over the document then yes I'd go that way

[Tutor] parsing Spreadsheet document

2009-12-09 Thread Christopher Spears
I want to fill a database with the contents of a spreadsheet. The spreadsheet was created by OpenOffice and is a .sxc document. What is the best way to do this? I think the best approach is to save the spreadsheet as a .csv document and then just parse the file. Am I on the right track here?

Re: [Tutor] parsing XML into a python dictionary

2009-11-15 Thread Stefan Behnel
Christopher Spears, 14.11.2009 19:47: > Thanks! I have a lot of XML files at work that users search through. I > want to parse the XML into a python dictionary and then read the dictionary > into a database that users can use to search through the thousands of files. I think "database" is the righ

Re: [Tutor] parsing XML into a python dictionary

2009-11-14 Thread Christopher Spears
erything under the "comic" tag. --- On Sat, 11/14/09, Kent Johnson wrote: > From: Kent Johnson > Subject: Re: [Tutor] parsing XML into a python dictionary > To: "Christopher Spears" > Cc: tutor@python.org > Date: Saturday, November 14, 2009, 5:03 AM &

Re: [Tutor] parsing XML into a python dictionary

2009-11-14 Thread Kent Johnson
On Sat, Nov 14, 2009 at 1:14 AM, Christopher Spears wrote: > I've been working on a way to parse an XML document and convert it into a > python dictionary.  I want to maintain the hierarchy of the XML.  Here is the > sample XML I have been working on: > > >   >    Neil Gaiman >    Glyn Dillon >

Re: [Tutor] parsing XML into a python dictionary

2009-11-14 Thread Alan Gauld
"Christopher Spears" wrote I've been working on a way to parse an XML document and convert it into a python dictionary. I want to maintain the hierarchy of the XML. Here is the sample XML I have been working on: Neil Gaiman Glyn Dillon Charles Vess This is my first stab at

[Tutor] parsing XML into a python dictionary

2009-11-13 Thread Christopher Spears
I've been working on a way to parse an XML document and convert it into a python dictionary. I want to maintain the hierarchy of the XML. Here is the sample XML I have been working on: Neil Gaiman Glyn Dillon Charles Vess This is my first stab at this: #!/usr/bin/env pyth

Re: [Tutor] parsing XML

2009-11-10 Thread Alan Gauld
"Stefan Behnel" wrote Note that ElementTree provides both a SAX-like interface (look for the 'target' property of parsers) and an incremental parser (iterparse). Interesting, I didn't realise that. I've only ever used it to build a tree. XML parsers fall into 2 groups. Those that parse the

Re: [Tutor] parsing XML

2009-11-10 Thread Stefan Behnel
Alan Gauld, 10.11.2009 06:53: > "Christopher Spears" wrote >> I need to parse several XML documents into a Python dictionary. Is >> there a module that would be particularly good for this? I heard >> beginners should start with ElementTree. However, SAX seems to make a >> little more sense to m

Re: [Tutor] parsing XML

2009-11-09 Thread Alan Gauld
"Christopher Spears" wrote I need to parse several XML documents into a Python dictionary. Is there a module that would be particularly good for this? I heard beginners should start with ElementTree. However, SAX seems to make a little more sense to me. XML parsers fall into 2 groups

Re: [Tutor] parsing XML

2009-11-09 Thread Eric Pavey
On Mon, Nov 9, 2009 at 7:48 PM, Christopher Spears wrote: > Hi! > > I need to parse several XML documents into a Python dictionary. Is there a > module that would be particularly good for this? I heard beginners should > start with ElementTree. However, SAX seems to make a little more sense to

[Tutor] parsing XML

2009-11-09 Thread Christopher Spears
Hi! I need to parse several XML documents into a Python dictionary. Is there a module that would be particularly good for this? I heard beginners should start with ElementTree. However, SAX seems to make a little more sense to me. Any suggestions? __

Re: [Tutor] Parsing html tables and using numpy for subsequent processing

2009-09-17 Thread David Kim
> > Gerard wrote: > Not very pretty, but I imagine there are very few pretty examples of > this kind of thing. I'll add more comments...honest. Nothing obviously > wrong with your code to my eyes. > Many thanks gerard, appreciate you looking it over. I'll take a look at the link you posted as well

Re: [Tutor] Parsing html tables and using numpy for subsequent processing

2009-09-16 Thread Gerard Flanagan
David Kim wrote: Hello all, I've finally gotten around to my 'learn how to parse html' project. For those of you looking for examples (like me!), hopefully it will show you one potentially thickheaded way to do it. [...] The code can be found at pastebin: http://financialpython.pastebin.com

Re: [Tutor] Parsing html tables and using numpy for subsequentprocessing

2009-09-16 Thread Alan Gauld
"David Kim" wrote > The code can be found at pastebin: > http://financialpython.pastebin.com/f4efd8930 Nothing to do with the parsing but I noticed: def get_files(path): ''' Get a list of all files in a given directory. Returns a list of filename strings. ''' files = os

[Tutor] Parsing html tables and using numpy for subsequent processing

2009-09-15 Thread David Kim
Hello all, I've finally gotten around to my 'learn how to parse html' project. For those of you looking for examples (like me!), hopefully it will show you one potentially thickheaded way to do it. For those of you with powerful python-fu, I would appreciate any feedback regarding the direction I

Re: [Tutor] Parsing Bible verses

2009-07-29 Thread tearsfornations
hey, i recently was working on some custom bible software and created an sqlite3 database of a few different bibles, one of which is the American Standard Version (ASV) which you can download here http://tearsfornations.hostcell.net/bibledoth/asv.bible.sqlite3 here is the create tables CREATE

Re: [Tutor] Parsing Bible verses

2009-05-25 Thread John Fouhy
2009/5/26 Eduardo Vieira : > Now, a little farther on the topic of a Bible database. I'm not sure > how I should proceed. I don't really have the db file I need, I will > have to generate it somehow, from a bible software, because the > version I want is for Portuguese. I have found a bible in sql,

  1   2   3   >