Python libraries for log mining and event abstraction? (possibly OT)

2008-06-24 Thread felciano
Hi -- I am trying to do some event abstraction to mine a set of HTTP logs. We have a pretty clean stateless architecture with user IDs that allows us to understand what is retrieved on each session, and should allow us to detect the higher-order user activity from the logs. Ideally I'd love a pyth

Checking for network connectivity

2008-06-19 Thread felciano
Hi -- Is there a clean pythonic way to check for network connectivity? I have a script that needs to run periodically on a laptop to create a local cache of some network files. I would like it to fail gracefully when disconnected, as well as issue a warning if it hasn't been able to connect for X

Re: Multiline CSV export to Excel produces unrecognized characters?

2008-03-24 Thread felciano
> > Any chance you are doing this on Windows and Excel doesn't like the > return+linefeed line endings that Windows produces when writing files in > text mode? Try 'wb' as mode for the output file. > > Ciao, > Marc 'BlackJack' Rintsch > Fixed! Can't believe I missed that... Thank you for

Multiline CSV export to Excel produces unrecognized characters?

2008-03-23 Thread felciano
Hi -- Is there a standard way to use the csv module to export data that contains multi-line values to Excel? I can get it mostly working, but Excel seems to have difficulty displaying the generated multi-line cells. The following reproduces the problem in python 2.5: import csv row = [1,"hello",

Re: Python plain-text database or library that supports joins?

2007-06-22 Thread felciano
> > i don't think that using flat text files as a database is common these > days. if you need relational database features what stops you from > using rdbms? if the only reason for that is some legacy system then > i'd still use in-memory sqlite database for all relational operations. > import, pr

Re: What was that web interaction library called again?

2007-06-22 Thread felciano
Maybe http://twill.idyll.org/ -- http://mail.python.org/mailman/listinfo/python-list

Python plain-text database or library that supports joins?

2007-06-22 Thread felciano
Hello -- Is there a convention, library or Pythonic idiom for performing lightweight relational operations on flatfiles? I frequently find myself writing code to do simple SQL-like operations between flat files, such as appending columns from one file to another, linked through a common id. For ex

Re: Escaping commas within parens in CSV parsing?

2005-07-01 Thread felciano
Thanks for all the postings. I can't change delimiter in the source itself, so I'm doing it temporarily just to handle the escaping: def splitWithEscapedCommasInParens(s, trim=False): pat = re.compile(r"(.+?\([^\(\),]*?),(.+?\).*)") while pat.search(s): s = re.sub(p

Escaping commas within parens in CSV parsing?

2005-06-30 Thread felciano
Hi -- I am trying to use the csv module to parse a column of values containing comma-delimited values with unusual escaping: AAA, BBB, CCC (some text, right here), DDD I want this to come back as: ["AAA", "BBB", "CCC (some text, right here)", "DDD"] I think this is probably non-standard escapi

Re: Pythonic list to bitflag mapping

2004-12-02 Thread Ramon Felciano
> Or can be used directly as an integer index to get a character > > >>> ['01'[x in a] for x in xrange(10)] > ['0', '0', '0', '1', '1', '0', '1', '0', '0', '0'] > Very cool -- this does the trick nicely and seems quite extensible, now that I get the basic idiom. Belated thanks for the quick re

Pythonic use of CSV module to skip headers?

2004-12-02 Thread Ramon Felciano
Hi -- I'm using the csv module to parse a tab-delimited file and wondered whether there was a more elegant way to skip an possible header line. I'm doing line = 0 reader = csv.reader(file(filename)) for row in reader: if (ignoreFirstLine & line == 0):