I'm trying to parse* a large file (> 5GB) of structured markup data. The data format is essentially XML but there is no explicit root element. What's the most efficient way to do that?
The problem with SAX parsers is that they require a root element, so either I've to add a pseudo element to the data stream (is there an equivalent to Ja...
Hi,
In Python, you can use a dictionary as the first argument to dict.fromkeys(), e.g.:
In [1]: d = {'a': 1, 'b': 2}
In [2]: dict.fromkeys(d)
Out[2]: {'a': None, 'b': None}
I tried to do the same with a dict-like object, but that always raises a KeyError, e.g.:
In [1]: class SemiDict:
...: def __init__(self):
...: ...
Hello, I've got a form, returned by Python mechanize Browser and got via forms() method. How can I perform XPath search inside form node, that is, among descendant nodes of the HTML form node? TIA
Upd:
How to save html code of the form?
...
How do I know if the results of my query either using the Query interface or the GqlQuery interface returned zero results? Would using .get() on zero results produce an error? If yes, what's the best way to handle it?
...
Any idea of a RESTful APIs in Django for GETTING information from a server?
What I want to do is fetch the errors from the server into a database.
For example:
The Live server has examplewebsite.com, any thing goes wrong with that website should POST the error, where the Django app GET the errors and insert them into the database.
...
Hi,
Is there a way to catch the contents of the PHP session variable $_SESSION['user_id'] with a mod_wsgi Python script? I'm running a script in the background that will decide whether or not the user may proceed to view the document.
I would like to do something like this:
def allow_access(environ, host):
allow_access = False
...
Hi everyone!
A quick SQLAlchemy question...
I have a class "Document" with attributes "Number" and "Date". I need to ensure that there's no duplicated number for the same year, is
there a way to have a UniqueConstraint on "Number + year(Date)"? Should I use a unique Index instead? How would I declare the functional part?
(SQLAlchemy...
One of the feature I like in RoR is the db management, it can hide all the sql statement, also, it is very easy to change different db in RoR, is there any similar framework in Python 3000?
...
I have an application that generates some large log files > 500MB.
I have written some utilities in Python that allows me to quickly browse the log file and find data of interest. But I now get some datasets where the file is too big to load it all into memory.
I thus want to scan the document once, build an index and then only load th...
I am looking for a link checker to spider my website and log invalid links, the problem is that I have a Login page at the start which is required. What i want is a link checker to run through the command post login details then spider the rest of the website.
Any ideas guys will be appreciated.
...
I'd like to refactor a number of django apps in a way which involves moving Models from one app into another where they can be more readily reused.
A number of these models have either ForeignKey relationships or M2M relationships to other models (such as User). For example:
class Department(models.Model):
name = models.CharField...
This is a follow-up to the question (Link)
What I intend on doing is using the XML to create a graph using NetworkX. Looking at the DOM structure below, all nodes within the same node should have an edge between them, and all nodes that have attended the same conference should have a node to that conference. To summarize, all authors...
I have this Python code:
import re
s = "aa67bc54c9"
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
And I get this error message when I try to run it:
File "<stdin>", line 1
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
^
SyntaxError: invalid syntax
How can I solve this? I ...
I'm using django-tagging, and am trying to retrieve a list of tags for a specific queryset. Here's what I've got:
tag = Tag.objects.get(name='tag_name')
queryset = TaggedItem.objects.get_by_model(Article, tag)
tags = Tag.objects.usage_for_queryset(queryset, counts=True)
"queryset" appropriately returns a number of articles th...
I have a list of many sentences in Excel on each row in a column. I have like 3 or more columns with such sentences. There are some common sentences in these. Is it possible to create a script to create a Venn diagram and get the common ones between all.
Example: These are sentences in a column. Similarly there are different columns.
...
How do I design a Django/Javascript application to provide for conditional Ajax responses to conventional HTTP requests?
On the server, I have a custom-built Form object. When the browser POSTS the form's data, the server checks the submitted data against existing data and rules (eg, if the form adds some entity to a database, does tha...
I would like to access the Foo instance foo within my manager method baz:
foo.bar_set.baz()
baz would normally take an argument of Foo type:
BarManager(models.Manager):
def baz(self, foo=None):
if foo is None:
# assume this call originates from
# a RelatedManager and set `foo`.
# Otherw...
import numpy
from numpy import asarray
Initial = numpy.asarray [2.0, 4.0, 5.0, 3.0, 5.0, 6.0] # Initial values to start with
bounds = [(1, 5000), (1, 6000), (2, 100000), (1, 50000), (1.0, 5000), (2, 1000000)]
# actual passed bounds
b1 = lambda x: numpy.asarray([1.4*x[0] - x[0]])
b2 = lambda x: numpy.asarray([1.4*x[1] - x[1...
Hi,
I am reading up on how to utilize Python Queues to send and receive short messages between nodes. I am simulating a set of nodes that are in a nice tree structure. I want some of these nodes to send a fixed-size data to its parent. Once this parent receives data from some of its child-nodes, it will "process" it and send a "aggr...
I have a Python app. It loads config files (and various other files) by
doing stuff such as:
_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CONFIG_DIR = os.path.join(_path, 'conf')
This works fine. However, when I package the app with py2exe, bad things happen:
File "proj\config.pyc", line 8, in <module>
Window...