From: <jb...@us...> - 2010-11-11 02:30:26
|
Revision: 693 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=693&view=rev Author: jblance Date: 2010-11-11 02:30:18 +0000 (Thu, 11 Nov 2010) Log Message: ----------- Bug fix to delimited import Modified Paths: -------------- pytrainer/trunk/pytrainer/gui/windowimportdata.py Modified: pytrainer/trunk/pytrainer/gui/windowimportdata.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 02:26:09 UTC (rev 692) +++ pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 02:30:18 UTC (rev 693) @@ -880,6 +880,8 @@ if self.has_header and i==0: #Ignore first row continue + if not row: + continue data = {} #Determine dates _date = Date().getDateTime(row[dateCol-1]) @@ -905,7 +907,7 @@ durationSec = int(h)*3600 + int(m)*60 + int(s) except: logging.debug("Error calculating duration for '%s'" % _duration) - print("Error calculating duration for '%s'" % _duration) + #print("Error calculating duration for '%s'" % _duration) durationSec = None else: try: @@ -913,7 +915,7 @@ except: #Unknown duration logging.debug("Could not determine duration for '%s'" % _duration) - print("Could not determine duration for '%s'" % _duration) + #print("Could not determine duration for '%s'" % _duration) durationSec = None if durationSec is not None: data['duration'] = durationSec @@ -982,7 +984,7 @@ data['comments'] = row[commentsCol-1] #Insert into DB - print "Data", data + logging.debug("Data", data) self.pytrainer_main.ddbb.insert_dict('records', data) #Display message.... self.updateStatusbar(self.statusbarCSVImport, "Import completed. %d rows processed" % i) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jb...@us...> - 2010-11-11 02:46:00
|
Revision: 695 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=695&view=rev Author: jblance Date: 2010-11-11 02:45:54 +0000 (Thu, 11 Nov 2010) Log Message: ----------- Bug fix to delimited import Modified Paths: -------------- pytrainer/trunk/pytrainer/gui/windowimportdata.py Modified: pytrainer/trunk/pytrainer/gui/windowimportdata.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 02:34:38 UTC (rev 694) +++ pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 02:45:54 UTC (rev 695) @@ -896,7 +896,9 @@ try: data['distance'] = locale.atof(row[distanceCol-1]) except: - pass + data['distance'] = 0 + else: + data['distance'] = 0 if durationCol: #calculate duration in sec... _duration = row[durationCol-1] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jb...@us...> - 2010-11-11 09:36:36
|
Revision: 697 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=697&view=rev Author: jblance Date: 2010-11-11 09:36:29 +0000 (Thu, 11 Nov 2010) Log Message: ----------- Fix typo in csv import Modified Paths: -------------- pytrainer/trunk/pytrainer/gui/windowimportdata.py Modified: pytrainer/trunk/pytrainer/gui/windowimportdata.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 08:56:45 UTC (rev 696) +++ pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 09:36:29 UTC (rev 697) @@ -198,7 +198,7 @@ self.checkbuttonAutoLaunch.set_active(1) logging.debug("<<") return - + def init_csvimport_tab(self): logging.debug(">>") #Populate Force Sport to combobox @@ -806,7 +806,7 @@ print len(reader.fieldnames) columns = [_("Column %d") % x for x in range(0, len(reader.fieldnames))] #print columns - + for column in columns: self.cbCSVDate.append_text(column) self.cbCSVDistance.append_text(column) @@ -843,7 +843,7 @@ def on_buttonCSVImport_clicked(self, widget): logging.debug('>>') - #Determine values + #Determine values dateCol = self.cbCSVDate.get_active() distanceCol = self.cbCSVDistance.get_active() durationCol = self.cbCSVDuration.get_active() @@ -859,14 +859,14 @@ paceCol = self.cbCSVPace.get_active() maxPaceCol = self.cbCSVMaxPace.get_active() commentsCol = self.cbCSVComments.get_active() - + #print dateCol, distanceCol, durationCol, titleCol, sportCol, avgspeedCol, maxspeedCol, calCol, accCol, desCol, hrCol, maxHRCol, paceCol, maxPaceCol, commentsCol - + if dateCol == 0: #Error need to have at least a date self.updateStatusbar(self.statusbarCSVImport, "ERROR: Must define at least a date column") return - + #Import... #Get selected file if not os.path.isfile(self.CSVfilename): @@ -875,7 +875,7 @@ csvfile = open(self.CSVfilename, 'rb') reader = csv.reader(csvfile, delimiter=self.delimiter) #Process File - + for i, row in enumerate(reader): if self.has_header and i==0: #Ignore first row @@ -883,7 +883,7 @@ if not row: continue data = {} - #Determine dates + #Determine dates _date = Date().getDateTime(row[dateCol-1]) #year, month, day = date.split("-") date = _date[1].strftime("%Y-%m-%d") @@ -935,56 +935,56 @@ self.comboCSVForceSport.set_active(0) sport_id = self.pytrainer_main.record.getSportId(self.comboCSVForceSport.get_active_text(),add=True) data['sport'] = sport_id - + if avgspeedCol: # try: - data['average'] = locale.atof(row[avgspeedCol-1]) + data['average'] = locale.atof(row[avgspeedCol-1]) except: pass if maxspeedCol: try: - data['maxspeed'] = locale.atof(row[maxspeedCol-1]) + data['maxspeed'] = locale.atof(row[maxspeedCol-1]) except: pass if calCol: try: - data['calories'] = locale.atoi(row[calCol-1]) + data['calories'] = locale.atoi(row[calCol-1]) except: pass if accCol: try: - data['upostive'] = locale.atof(row[accCol-1]) + data['upositive'] = locale.atof(row[accCol-1]) except: pass if desCol: try: - data['unegative'] = locale.atof(row[desCol-1]) + data['unegative'] = locale.atof(row[desCol-1]) except: pass if hrCol: try: - data['beats'] = locale.atof(row[hrCol-1]) + data['beats'] = locale.atof(row[hrCol-1]) except: pass if maxHRCol: try: - data['maxbeats'] = locale.atof(row[maxHRCol-1]) + data['maxbeats'] = locale.atof(row[maxHRCol-1]) except: pass if paceCol: try: - data['pace'] = locale.atof(row[paceCol-1]) + data['pace'] = locale.atof(row[paceCol-1]) except: pass if maxPaceCol: try: - data['maxpace'] = locale.atof(row[maxPaceCol-1]) + data['maxpace'] = locale.atof(row[maxPaceCol-1]) except: pass if commentsCol: - data['comments'] = row[commentsCol-1] - + data['comments'] = row[commentsCol-1] + #Insert into DB logging.debug("Data", data) self.pytrainer_main.ddbb.insert_dict('records', data) @@ -992,5 +992,5 @@ self.updateStatusbar(self.statusbarCSVImport, "Import completed. %d rows processed" % i) #Disable import button self.buttonCSVImport.set_sensitive(0) - + logging.debug('<<') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jb...@us...> - 2010-11-11 20:01:29
|
Revision: 701 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=701&view=rev Author: jblance Date: 2010-11-11 20:01:23 +0000 (Thu, 11 Nov 2010) Log Message: ----------- Bug fix for delimited import Modified Paths: -------------- pytrainer/trunk/pytrainer/gui/windowimportdata.py Modified: pytrainer/trunk/pytrainer/gui/windowimportdata.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 13:24:45 UTC (rev 700) +++ pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-11 20:01:23 UTC (rev 701) @@ -901,7 +901,10 @@ data['distance'] = 0 if durationCol: #calculate duration in sec... - _duration = row[durationCol-1] + try: + _duration = row[durationCol-1] + except: + _duration = 0 if _duration.count(':') == 2: #Have 00:00:00 duration h, m, s = _duration.split(':') @@ -923,7 +926,10 @@ data['duration'] = durationSec data['time'] = str(durationSec) if titleCol: - data['title'] = row[titleCol-1] + try: + data['title'] = row[titleCol-1] + except: + pass if self.checkbCSVForceSport.get_active(): sport_id = self.pytrainer_main.record.getSportId(self.comboCSVForceSport.get_active_text(),add=True) data['sport'] = sport_id @@ -983,7 +989,10 @@ except: pass if commentsCol: - data['comments'] = row[commentsCol-1] + try: + data['comments'] = row[commentsCol--1] + except: + pass #Insert into DB logging.debug("Data", data) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |