Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread Sivaram Neelakantan
On Sun, Feb 09 2014,Peter Otten wrote: > Sivaram Neelakantan wrote: > [snipped 32 lines] > > If nobody here comes up with a good way to find the offending record you > could ask in a mailing list/newsgroup dedicated to sqlite (Please report > back here if you do). If the

Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread Sivaram Neelakantan
On Sun, Feb 09 2014,Steven D'Aprano wrote: > On Sun, Feb 09, 2014 at 12:03:43PM +0530, Sivaram Neelakantan wrote: > [snipped 8 lines] > When you get an error, and don't know how to interpret it, the first > thing to do is to look at the exception and see what it says. >

[Tutor] catching the row that raises IntegrityError in sqlite

2014-02-08 Thread Sivaram Neelakantan
I've written this code that seems to work and I'd like to know how to get the record that causes the abort. Apparently 'executemany' doesn't support lastrow? And if it doesn't, any suggestions? --8<---cut here---start->8--- def table_load(datafile,name,conn,d

Re: [Tutor] Reading CSV files in Pandas

2013-10-20 Thread Sivaram Neelakantan
On Sat, Oct 19 2013,Manish Tripathi wrote: > I am trying to import a csv file in Pandas but it throws an error. The > format of the data when opened in notepad++ is as follows with first row > being column names: you could try the following newsgroup or mailing list for more specialised help.

Re: [Tutor] Reading CSV files in Pandas

2013-10-20 Thread Sivaram Neelakantan
On Sun, Oct 20 2013,Mark Lawrence wrote: > On 19/10/2013 23:40, Alan Gauld wrote: > >> This is the second time I've seen pandas mentioned recedntly I really >> must go and look it up to find out what it is... > > Just started out myself at http://pandas.pydata.org/ and at first > glance it seems q

Re: [Tutor] Processing CSV files

2013-10-09 Thread Sivaram Neelakantan
On Wed, Oct 09 2013,Leena Gupta wrote: > Hello, > > Looking for some inputs on Python's csv processing feature. > > I need to process a large csv file every 5-10 minutes. The file could > contain 3mill to 10 mill rows and size could be 6MB to 10MB(+). As part of > the processing, I need to sum up

Re: [Tutor] appending/updating values dict key value pairs

2013-06-23 Thread Sivaram Neelakantan
On Sun, Jun 23 2013,eryksun wrote: [snipped 14 lines] > The correct syntax is a dict of dicts: > > {'a': {'foo': 1, 'bar': 2, 'offset': 'fff'}} > > A dict is something of a resource hog, and it's unordered. Use it as > the container because it's mutable and lookups are fast, but for the > v

Re: [Tutor] appending/updating values dict key value pairs

2013-06-23 Thread Sivaram Neelakantan
On Sun, Jun 23 2013,Steven D'Aprano wrote: > On 23/06/13 19:42, Sivaram Neelakantan wrote: [snipped 28 lines] > Python doesn't have structs in the sense you mean. (But see below > for alternatives.) There is a struct module for working with > low-level C-style bytes,

Re: [Tutor] appending/updating values dict key value pairs

2013-06-23 Thread Sivaram Neelakantan
On Sun, Jun 23 2013,Alan Gauld wrote: [snipped 21 lines] > But we normally call methods via the object instance rather than the > class so simplifying this further we get: > > b['a'].append('c') > Thanks for the detailed explanation. I've sort of used a dict of this sort {'a': [1,2,'fff'] } in

Re: [Tutor] appending/updating values dict key value pairs

2013-06-22 Thread Sivaram Neelakantan
On Sat, Jun 22 2013,Mark Lawrence wrote: [snipped 7 lines] > b = { 'a': [4, 5]} > list.append(b.get('a'),'c') > b >> {'a': [4, 5, 'c']} > >> >> >> as in, shouldn't it be >> >> b['a'] = list.append(b.get('a'),'c') >> >> which doesn't seem to work. >> >> sivaram >> -- > > b['a'

[Tutor] appending/updating values dict key value pairs

2013-06-22 Thread Sivaram Neelakantan
What's the best way to append to the list which is the value to a dict key? I did the following based on the docs and I'm not sure why it works >>> b = { 'a': [4, 5]} >>> list.append(b.get('a'),'c') >>> b {'a': [4, 5, 'c']} >>> as in, shouldn't it be b['a'] = list.append(b.get('a'),'c') wh

[Tutor] initialising all elements of a matrix

2012-02-28 Thread Sivaram Neelakantan
I was wondering whether there is a faster/better/cleaner way of element wise operations of arbitrarily nested list. I wrote something like this for 1 level nested lists and am wondering whether there are any good idioms in python. I did this after a ridiculous amount of bad thinking/missteps in

[Tutor] Suggestions for a good intro OO & Python

2012-02-24 Thread Sivaram Neelakantan
Can someone point me to a good intro on OO in Python? If it does OO basics too, even better, assuming no prior knowledge of Object Orientation. sivaram -- ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http:

Re: [Tutor] Class definition confusion

2012-02-15 Thread Sivaram Neelakantan
On Thu, Feb 16 2012,Alan Gauld wrote: [snipped 19 lines] > Python allows instance attributes to be added at runtime. > In general this is a bad idea IMHO, a dictionary would probably > be more appropriate, but there can, very occasionally, be valid > uses for it. Thanks for that, I kept thinkin

[Tutor] Class definition confusion

2012-02-15 Thread Sivaram Neelakantan
I was under the impression that you have to define the attributes of the class before using it in an instance. Following the book 'thinking in Python', >>> class Point: ... """pts in 2d space""" ... >>> print Point __main__.Point >>> b = Point() >>> b.x =3 >>> b.y =4 >>> print b.y 4 >>> Why

Re: [Tutor] Return T/F vs print T/F

2012-02-04 Thread Sivaram Neelakantan
On Sat, Feb 04 2012,bob gailer wrote: > On 2/4/2012 9:38 AM, Sivaram Neelakantan wrote: >> While trying out code, I have trouble following the difference between >> >> return True vs print True and the same with False. If I use return >> for the True/False statements,

[Tutor] Return T/F vs print T/F

2012-02-04 Thread Sivaram Neelakantan
While trying out code, I have trouble following the difference between return True vs print True and the same with False. If I use return for the True/False statements, nothing gets printed. Why? And if I add a print before the function call I get an output like >>>True None --8<---