[Tutor] array of different datatypes

2008-09-22 Thread Dinesh B Vadhia
I have looked (honestly!) and cannot see an array structure to allow different datatypes per column. I need a 2 column array with column 1 = an integer and column 2 = chars, and after populating the array, sort on column 2 with column 1 sorted relatively. Thanks! Dinesh

Re: [Tutor] array of different datatypes

2008-09-22 Thread Dinesh B Vadhia
Thanks Steve. How do you sort on the second element of each list to get: a' = [[42, 'fish'], [1, 'hello'] [2, 'world'] ] From: Steve Willoughby Sent: Monday, September 22, 2008 8:16 PM To: Dinesh B Vadhia Cc: tutor@python.org Subj

[Tutor] defaultdict(set)

2008-09-25 Thread Dinesh B Vadhia
I'm using defaultdict(set) to store a dictionary d = {value : set_items} where value = integer and set_items = set() of characters and it works perfectly. I would like to also store the length of the set ie. l = len(set_items) with the dictionary but don't how to do it using a defaultdict(). A

[Tutor] XML to text

2008-10-24 Thread Dinesh B Vadhia
I have a large number of xml files that I want to convert into text format. What is the best and easiest way to do this? Thanks! Dinesh ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] XML to text

2008-10-24 Thread Dinesh B Vadhia
Yes, that's exactly what I was looking for. Brilliant! From: Kent Johnson Sent: Friday, October 24, 2008 10:59 AM To: Dinesh B Vadhia Cc: tutor@python.org Subject: Re: [Tutor] XML to text On Fri, Oct 24, 2008 at 11:54 AM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > I have

[Tutor] fast list traversal

2008-10-30 Thread Dinesh B Vadhia
I need to process a large number (> 20,000) of long and variable length lists (> 5,000 elements) ie. for element in long_list: # the result of this operation is not a list The performance is reasonable but I wonder if there are faster Python methods? Dinesh

Re: [Tutor] fast list traversal

2008-10-30 Thread Dinesh B Vadhia
Bob: Nothing special is being done on the elements of the list - additions/subtractions/ - and storing the results in an array. That's it. Dinesh From: bob gailer Sent: Thursday, October 30, 2008 11:40 AM To: Dinesh B Vadhia Cc: tutor@python.org Subject: Re: [Tutor] fast list trav

[Tutor] unordered and ordered defaultdict(set)

2008-10-30 Thread Dinesh B Vadhia
Here is an interesting result with defaultdict(set). This program creates 2 dictionaries of sets with the first dictionary containing 10 elements per set and the second containing 25 elements. You'll see the sets in the first dictionary are unordered and in the second they are ordered. impor

Re: [Tutor] fast list traversal

2008-10-30 Thread Dinesh B Vadhia
a for-loop. Btw, cannot move to Python 2.6 or 3.0 until Numpy/Scipy catches up. Dinesh From: wesley chun Sent: Thursday, October 30, 2008 3:06 PM To: Dinesh B Vadhia Cc: tutor@python.org Subject: Re: [Tutor] fast list traversal based on the all the performance questions, i would say agree

Re: [Tutor] fast list traversal

2008-10-31 Thread Dinesh B Vadhia
Hi Kent The code is very simple: dict_long_lists = defaultdict(list) for long_list in dict_long_lists.itervalues() for element in long_list: array_a[element] = m + n + p# m,n,p are numbers The long_list's are read from a defaultdict(list) dictionary and so don't n

[Tutor] pickling, writing, reading individual lists from a file

2008-11-02 Thread Dinesh B Vadhia
I want to pickle a bunch of lists and write each list separately to a fileand then read them back. Here is my code with the EOF error: import cPickle as pickle m = [[1, 2, 3, 4], [5, 6, 7, 8, 9, 10], [11, 12, 13, 14]] filename = 'lists.txt' fw = open(filename, 'w') for l in m: n = pick

Re: [Tutor] pickling, writing, reading individual lists from a file

2008-11-03 Thread Dinesh B Vadhia
, 2008 at 6:15 AM, Lie Ryan gmail.com> wrote: > On Sun, 02 Nov 2008 23:20:47 -0800, Dinesh B Vadhia wrote: > >> I want to pickle a bunch of lists and write each list separately to a >> fileand then read them back. > To solve your problem, you have several alternative possib

[Tutor] Decimal fixed point representation

2008-11-20 Thread Dinesh B Vadhia
I'm trying to get my head around the Decimal module to understand how to represent a decimal floating point number as an integer (or integers). Am I barking mad or is this possible? Dinesh ___ Tutor maillist - Tutor@python.org http://mail.python.or

Re: [Tutor] Decimal fixed point representation

2008-11-21 Thread Dinesh B Vadhia
To: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original "Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote > I'm trying to get my head around the Decimal module to > understand how

[Tutor] Reading gzip files

2008-11-30 Thread Dinesh B Vadhia
I'm reading gzip files and writing the content out to a text file line by line. The code is simply: import gzip list_zipfiles = dircache.listdir(zipfolder) writefile = "out_file.txt" fw = open(writefile, 'w') for ziparchive in list_zipfiles: zfile = gzip.GzipFile(zipfolder + ziparchive, "r

Re: [Tutor] Reading gzip files

2008-11-30 Thread Dinesh B Vadhia
ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original "Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote > I'm reading gzip files and writing the content out to a text file > line by line. > File "C:\P

[Tutor] Python on 64-bit ...

2008-12-07 Thread Dinesh B Vadhia
I ask this question in trepidation but does anyone have experience of Python on 64-bit Windows Vista - there I said it! Feedback on performance and memory usage would be useful to know. Thanks! Dinesh___ Tutor maillist - Tutor@python.org http://ma

[Tutor] Fw: Reading gzip files

2008-12-16 Thread Dinesh B Vadhia
offending file and move on to the next file in the list. How do I achieve this with this particular type of error? Dinesh From: Dinesh B Vadhia Sent: Sunday, November 30, 2008 2:51 PM To: tutor@python.org Subject: Reading gzip files I'm reading gzip files and writing the content out

[Tutor] Traversing XML Tree with ElementTree

2009-01-24 Thread Dinesh B Vadhia
I want to traverse an xml file and at each node retain the full path from the parent to that node ie. if we have: this is node b this is node c this is node d this is node e ... then require: this is node b this is node c t

[Tutor] Fw: Traversing XML Tree with ElementTree

2009-01-24 Thread Dinesh B Vadhia
i've got most of this working now so hold off (for now). thanks. dinesh From: Dinesh B Vadhia Sent: Saturday, January 24, 2009 8:31 PM To: tutor@python.org Subject: Traversing XML Tree with ElementTree I want to traverse an xml file and at each node retain the full path from the p

[Tutor] Eliminating options

2009-02-04 Thread Dinesh B Vadhia
Hi! I'm using 32-bit Python on Windows 64-bit Vista (instead of 64-bit Python because I also use Numpy/Scipy which doesn't offer 64-bit versions yet). I'm doing some very simple text processing ie. given a string s, find a subtring using s.find(). But, the program doesn't find all instances o

[Tutor] Picking up citations

2009-02-06 Thread Dinesh B Vadhia
Hi! I want to process text that contains citations, in this case in legal documents, and pull-out each individual citation. Here is a sample text: text = "Page 500 Carter v. Jury Commission of Greene County, 396 U.S. 320, 90 S.Ct. 518, 24 L.Ed.2d 549 (1970); Lathe Turner v. Fouche, 396 U.S. 34

Re: [Tutor] Picking up citations

2009-02-07 Thread Dinesh B Vadhia
n petit jury, he would clearly have standing to challenge the systematic exclusion of any identifiable group from jury service." Okay, I'd better get to grips with pyparsing! Dinesh From: Kent Johnson Sent: Saturday, February 07, 2009 6:21 AM To: Dinesh B Vadhia Cc: tutor@pytho

Re: [Tutor] Picking up citations

2009-02-07 Thread Dinesh B Vadhia
, 493 U.S. 146, 159-60 (1934)" I didn't know about pyparsing which appears to be very powerful and have joined their list. Thank-you for your help. Dinesh From: Kent Johnson Sent: Saturday, February 07, 2009 1:19 PM To: Dinesh B Vadhia Cc: tutor@python.org Subject: Re: [Tutor]

Re: [Tutor] Picking up citations

2009-02-09 Thread Dinesh B Vadhia
Kent /Emmanuel Below are the results using the PLY parser and Regex versions on the attached 'sierra' data which I think covers the common formats. Here are some 'fully unparsed" citations that were missed by the programs: Smith v. Wisconsin Dept. of Agriculture, 23 F.3d 1134, 1141 (7th Cir.1

[Tutor] Picking up citations

2009-02-09 Thread Dinesh B Vadhia
Kent /Emmanuel I found a list of words before the first word that can be removed which I think is the only way to successfully parse the citations. Here they are: | E.g. | Accord | See |See + Also | Cf. | Compare | Contra | But + See | But + Cf. | See Generally | Citing | In | Dinesh

[Tutor] Sorting multiple sequences

2011-03-11 Thread Dinesh B Vadhia
I want to sort two sequences with different data types but both with an equal number of elements eg. f = [0.21, 0.68, 0.44, ..., 0.23] i = [6, 18, 3, ..., 45] The obvious solution is to use zip ie. pairs = zip(f,i) followed by pairs.sort(). This is fine but my sequences contain 10,000+ element

Re: [Tutor] Sorting multiple sequences

2011-03-12 Thread Dinesh B Vadhia
11:16:30 +1100 From: Steven D'Aprano To: tutor@python.org Subject: Re: [Tutor] Sorting multiple sequences Message-ID: <4d7abb5e.9080...@pearwood.info> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Dinesh B Vadhia wrote: > I want to sort two sequences with different

[Tutor] Python sqlite with implicit cursor open and close

2012-05-18 Thread Dinesh B Vadhia
In the Python documentation (http://docs.python.org/library/sqlite3.html?highlight=sqlite#using-shortcut-methods) it says: "Using the nonstandard execute(), executemany() and executescript() methods of the Connection object, your code can be written more concisely because you don't have to crea

<    1   2