From: <jb...@us...> - 2010-11-10 21:59:06
|
Revision: 690 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=690&view=rev Author: jblance Date: 2010-11-10 21:59:00 +0000 (Wed, 10 Nov 2010) Log Message: ----------- CSV Import changes Modified Paths: -------------- pytrainer/trunk/glade/importdata.glade pytrainer/trunk/pytrainer/gui/windowimportdata.py pytrainer/trunk/pytrainer/main.py Modified: pytrainer/trunk/glade/importdata.glade =================================================================== --- pytrainer/trunk/glade/importdata.glade 2010-11-10 09:35:17 UTC (rev 689) +++ pytrainer/trunk/glade/importdata.glade 2010-11-10 21:59:00 UTC (rev 690) @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <glade-interface> <!-- interface-requires gtk+ 2.16 --> <!-- interface-naming-policy toplevel-contextual --> @@ -778,7 +778,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="max_length">5</property> - <property name="invisible_char">•</property> + <property name="invisible_char">•</property> <property name="width_chars">5</property> </widget> <packing> @@ -834,9 +834,198 @@ </packing> </child> <child> - <placeholder/> + <widget class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <child> + <widget class="GtkAlignment" id="alignment8"> + <property name="visible">True</property> + <property name="left_padding">12</property> + <child> + <widget class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">5</property> + <property name="n_columns">3</property> + <child> + <widget class="GtkLabel" id="labelCSVDate"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Date</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkComboBox" id="cbCSVDate"> + <property name="visible">True</property> + <property name="active">0</property> + <property name="items" translatable="yes">Exclude</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelCSVDistance"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Distance</property> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelCSVDuration"> + <property name="visible">True</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Duration</property> + </widget> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkComboBox" id="cbCSVDistance"> + <property name="visible">True</property> + <property name="active">0</property> + <property name="items" translatable="yes">Exclude</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkComboBox" id="cbCSVDuration"> + <property name="visible">True</property> + <property name="active">0</property> + <property name="items" translatable="yes">Exclude</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelCSVDataField"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>PyTrainer Field</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="labelCSVFileCol"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>File Column</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkLabel" id="labelCSVColumns"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Map Columns</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">5</property> + <property name="position">3</property> + </packing> </child> <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <widget class="GtkButton" id="buttonCSVImport"> + <property name="label" translatable="yes">Import Data</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">end</property> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">4</property> + </packing> + </child> + <child> <widget class="GtkStatusbar" id="statusbarCSVImport"> <property name="visible">True</property> <property name="spacing">2</property> Modified: pytrainer/trunk/pytrainer/gui/windowimportdata.py =================================================================== --- pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-10 09:35:17 UTC (rev 689) +++ pytrainer/trunk/pytrainer/gui/windowimportdata.py 2010-11-10 21:59:00 UTC (rev 690) @@ -752,6 +752,7 @@ self.updateStatusbar(self.statusbarCSVImport, "Got file: " + filename) #Enable buttons self.buttonCSVProcess.set_sensitive(True) + self.buttonCSVImport.set_sensitive(True) def on_buttonCSVProcess_clicked(self, widget): #Get selected file @@ -770,9 +771,29 @@ #Read as delimited file csvfile = open(filename, 'rb') + #See if file has header row + has_header = csv.Sniffer().has_header(csvfile.read(1024)) + csvfile.seek(0) reader = csv.DictReader(csvfile, delimiter=delimiter) + #Read file to determine fields (must be a better way of doing this) for row in reader: pass - #print reader.fieldnames + #Build array of column names + if has_header: + #If the file has a header row, use the actual column names + columns = reader.fieldnames + else: + #Otherwise just label them with numbers + 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) + self.cbCSVDuration.append_text(column) + self.cbCSVDate.set_active(0) + self.cbCSVDistance.set_active(0) + self.cbCSVDuration.set_active(0) Modified: pytrainer/trunk/pytrainer/main.py =================================================================== --- pytrainer/trunk/pytrainer/main.py 2010-11-10 09:35:17 UTC (rev 689) +++ pytrainer/trunk/pytrainer/main.py 2010-11-10 21:59:00 UTC (rev 690) @@ -50,7 +50,7 @@ class pyTrainer: def __init__(self,filename = None, data_path = None): #Version constants - self.version ="1.7.2_svn#689" + self.version ="1.7.2_svn#690" self.DB_version = 6 #Process command line options self.startup_options = self.get_options() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |