Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: attribute of type 'NoneType' is not callable object
#1
Hi all,

I'm working on my python script as I'm pulling the data from the sqlite3 database. I'm trying to convert the string object to datetime object, but I have got a problem with the code as I get the error when I'm trying convert from the string object to datetime object.

The error I'm getting is: TypeError: attribute of type 'NoneType' is not callable

The error are jumping on this line:

Code:
program_startdate = datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")




Here is example the results from the sqlite3 database:

Code:
20140520170000
20140520170000
20140520170000
20140520170000
20140520170000
20140520170000
20140520170000



Here is the code:

Code:
#get the channels list
cur.execute('SELECT channel FROM programs WHERE channel GROUP BY channel')


for row in cur:
    channels = row[0].encode('ascii')
    channelList.append(channels)

    # set the channels text
    for index in range(0, CHANNELS_PER_PAGE):
        channel = channelList[index]


        if channel is not None:
           self.getControl(4110 + index).setLabel(channel)
           #get the programs list
           cur.execute('SELECT channel, title, start_date, stop_date FROM programs WHERE channel="channel"')
           programList = list()
           programs = cur.fetchall()


           for row in programs:
               program = row[1].encode('ascii'), str(row[2]), str(row[3])
               #print program
               #print datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")
               program_startdate = datetime.datetime.strptime(str(row[2]), "%Y%m%d%H%M%S")
               #program_endDate = datetime.datetime.strptime(str(row[3]), "%Y%m%d%H%M%S")
               programList.append(program)


               # find nearest half hour
               viewStartDate = datetime.datetime.now()
               viewStartDate -= datetime.timedelta(minutes = viewStartDate.minute % 30, seconds = viewStartDate.second)

               #convert the datetime object between start and end date
               startDelta = program_startdate - viewStartDate
               #stopDelta = program_endDate - viewStartDate
               #print startDelta, stopDelta   # check if you're getting the result you want
               #cellStart = self._secondsToXposition(startDelta.seconds)
           cur.close()



I'm using python version 2.6.

Can you please help me how to fix the code to get rid of the error?

Thanks in advance
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Module attribute problems. goqe 0 667 03-18-2013, 11:38 AM
Last Post: goqe
  'X' object has no attribute 'y' band_master 1 1,085 04-23-2012, 09:54 PM
Last Post: band_master
  [Guide] Object Serialization in Python manipulate 3 1,429 08-12-2011, 10:39 AM
Last Post: BreShiE
  Example of Object Oriented Programming nevets04 1 979 11-16-2009, 04:17 PM
Last Post: Fallen
  Calculator Using Object Oriented Programming nevets04 1 2,265 11-16-2009, 04:12 PM
Last Post: Fallen

Forum Jump:


Users browsing this thread: 1 Guest(s)