Hi Bryan -

I've hacked a patch for doing imports ignoring text lines and adding or 
prepending a filename (or other text) to the dataset names. It also splits 
the import help to another window (not sure this is a good idea, but it 
makes the dialog cleaner).

It's not quite finished:
 - Needs to document that $FILENAME is required to add filename to dataset 
names - should be in drop down list to make it obvious
 - User interface needs tidy up.
 - Default value of ignoring text should probably be true and value should 
be remembered between imports.

You haven't started working on this yet have you?

Jeremy

Index: dialogs/importdialog.py
===================================================================
--- dialogs/importdialog.py	(revision 918)
+++ dialogs/importdialog.py	(working copy)
@@ -33,6 +33,14 @@
 
 pyfits = None
 
+class ImportStandardHelpDialog(qt4.QDialog):
+    """Class to load help for standard veusz import."""
+    def __init__(self, parent, *args):
+        qt4.QDialog.__init__(self, parent, *args)
+        qt4.loadUi(os.path.join(utils.veuszDirectory, 'dialogs',
+                                'importhelp.ui'),
+                   self)
+
 class ImportDialog2(qt4.QDialog):
 
     dirname = '.'
@@ -55,6 +63,10 @@
         self.connect( self.importbutton, qt4.SIGNAL('clicked()'),
                       self.slotImport)
 
+        # user wants help about standard import
+        self.connect( self.helpbutton, qt4.SIGNAL('clicked()'),
+                      self.slotHelp )
+
         # notification tab has changed
         self.connect( self.methodtab, qt4.SIGNAL('currentChanged(int)'),
                       self.slotUpdatePreview )
@@ -107,6 +119,11 @@
             ImportDialog2.dirname = fd.directory().absolutePath()
             self.filenameedit.replaceAndAddHistory( fd.selectedFiles()[0] )
 
+    def slotHelp(self):
+        """Asked for help for standard import."""
+        self.helpdialog = ImportStandardHelpDialog(self)
+        self.helpdialog.show()
+
     def slotUpdatePreview(self, *args):
         """Update preview window when filename or tab changed."""
 
@@ -377,12 +394,22 @@
         # convert controls to values
         descriptor = unicode( self.descriptoredit.text() )
         useblocks = self.blockcheckbox.isChecked()
-        
+        ignoretext = self.ignoretextcheckbox.isChecked()
+
+        # substitute filename if required
+        f = utils.escapeDatasetName( os.path.basename(filename) )
+        prefix = unicode( self.prefixcombo.lineEdit().text() )
+        prefix = prefix.replace('$FILENAME', f)
+        suffix = unicode( self.suffixcombo.lineEdit().text() )
+        suffix = suffix.replace('$FILENAME', f)
+
         try:
             # construct operation. this checks the descriptor.
             op = document.OperationDataImport(descriptor, filename=filename,
                                               useblocks=useblocks, 
-                                              linked=linked)
+                                              linked=linked,
+                                              prefix=prefix, suffix=suffix,
+                                              ignoretext=ignoretext)
 
         except document.DescriptorError:
             mb = qt4.QMessageBox("Veusz",
Index: dialogs/import.ui
===================================================================
--- dialogs/import.ui	(revision 918)
+++ dialogs/import.ui	(working copy)
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>645</width>
-    <height>600</height>
+    <height>640</height>
    </rect>
   </property>
   <property name="windowTitle" >
@@ -62,7 +62,7 @@
       <attribute name="title" >
        <string>&amp;Standard</string>
       </attribute>
-      <layout class="QVBoxLayout" name="verticalLayout_4" >
+      <layout class="QVBoxLayout" name="verticalLayout_5" >
        <item>
         <widget class="QLabel" name="label_7" >
          <property name="text" >
@@ -105,45 +105,96 @@
            </property>
           </widget>
          </item>
+         <item>
+          <widget class="QPushButton" name="helpbutton" >
+           <property name="text" >
+            <string>Help</string>
+           </property>
+          </widget>
+         </item>
         </layout>
        </item>
        <item>
-        <widget class="QLabel" name="label_3" >
-         <property name="sizePolicy" >
-          <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text" >
-          <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
-&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
-p, li { white-space: pre-wrap; }
-&lt;/style>&lt;/head>&lt;body>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Enter the dataset names separated by spaces. Optionally ",+-" and ",+,-" can be added to the name to specify that the following columns contain errors for that dataset.&lt;/p>
-&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">e.g.	&lt;span style=" font-style:italic;">x y&lt;/span>	x and y with no errors - 2 columns for 2 datasets&lt;/p>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">	&lt;span style=" font-style:italic;">x,+-&lt;/span>	x with symmetric errors - 2 columns for dataset&lt;/p>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">	&lt;span style=" font-style:italic;">y,+,-&lt;/span>	y with asymmetric errors - 3 columns for dataset&lt;/p>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">	&lt;span style=" font-style:italic;">x[1:5],+,-&lt;/span>	x_1 to x_5, each with asymmetric errors - 15 columns in total&lt;/p>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">	&lt;span style=" font-style:italic;">x y,+-&lt;/span>	x with no errors, y with symmetric errors - 3 columns in total&lt;/p>
-&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string>
-         </property>
-         <property name="wordWrap" >
-          <bool>true</bool>
-         </property>
-        </widget>
+        <layout class="QHBoxLayout" name="horizontalLayout_3" >
+         <item>
+          <widget class="QGroupBox" name="groupBox" >
+           <property name="title" >
+            <string>Options</string>
+           </property>
+           <layout class="QVBoxLayout" name="verticalLayout_4" >
+            <item>
+             <widget class="QCheckBox" name="blockcheckbox" >
+              <property name="toolTip" >
+               <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If this is selected, blank lines or the word "no" are used to separate the file into blocks. An underscore followed by the block number is added to the dataset names&lt;/p>&lt;/body>&lt;/html></string>
+              </property>
+              <property name="text" >
+               <string>Read data in bloc&amp;ks</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QCheckBox" name="ignoretextcheckbox" >
+              <property name="toolTip" >
+               <string>Ignores lines consisting of text when importing the data</string>
+              </property>
+              <property name="text" >
+               <string>I&amp;gnore text lines</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout" >
+              <item>
+               <widget class="QLabel" name="label_21" >
+                <property name="text" >
+                 <string>&amp;Prefix</string>
+                </property>
+                <property name="buddy" >
+                 <cstring>prefixcombo</cstring>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QComboBox" name="prefixcombo" >
+                <property name="toolTip" >
+                 <string>Prefix to prepend to each dataset name imported, or choose Filename to get filename prepended</string>
+                </property>
+                <property name="editable" >
+                 <bool>true</bool>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_2" >
+              <item>
+               <widget class="QLabel" name="label_22" >
+                <property name="text" >
+                 <string>Suffi&amp;x</string>
+                </property>
+                <property name="buddy" >
+                 <cstring>suffixcombo</cstring>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QComboBox" name="suffixcombo" >
+                <property name="toolTip" >
+                 <string>Suffix to append to each dataset name imported, or choose Filename to get filename appended</string>
+                </property>
+                <property name="editable" >
+                 <bool>true</bool>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+           </layout>
+          </widget>
+         </item>
+        </layout>
        </item>
-       <item>
-        <widget class="QCheckBox" name="blockcheckbox" >
-         <property name="toolTip" >
-          <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If this is selected, blank lines or the word "no" are used to separate the file into blocks. An underscore followed by the block number is added to the dataset names&lt;/p>&lt;/body>&lt;/html></string>
-         </property>
-         <property name="text" >
-          <string>Read data in bloc&amp;ks</string>
-         </property>
-        </widget>
-       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="csvtab" >
@@ -598,6 +649,8 @@
     </layout>
    </item>
   </layout>
+  <zorder>linkcheckbox</zorder>
+  <zorder>methodtab</zorder>
  </widget>
  <layoutdefault spacing="6" margin="11" />
  <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
Index: dialogs/importhelp.ui
===================================================================
--- dialogs/importhelp.ui	(revision 0)
+++ dialogs/importhelp.ui	(revision 0)
@@ -0,0 +1,85 @@
+<ui version="4.0" >
+ <class>ImportHelpDialog</class>
+ <widget class="QDialog" name="ImportHelpDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>581</width>
+    <height>368</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Import data help</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" >
+   <item>
+    <widget class="QTextEdit" name="textEdit" >
+     <property name="readOnly" >
+      <bool>true</bool>
+     </property>
+     <property name="html" >
+      <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:10pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Veusz assumes that data are stored as columns in a text file separated by tabs or spaces. Names should be entered for the datasets read from each column, separated by spaces (in the dataset names or descriptor box).&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If you want to supply errors or uncertainties on the data, these can be given in the columns following the dataset column (one column for symmetric errors or two for asymmetric errors). To tell Veusz that a dataset has errors, add "&lt;span style=" font-family:'Courier New,courier';">,+-&lt;/span>" or "&lt;span style=" font-family:'Courier New,courier';">,+,-&lt;/span>" to the dataset name to specify symmetric or asymmetric errors, respectively.&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Examples&lt;/span>&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-family:'Courier New,courier';">x y&lt;/span>	x and y with no errors  (2 columns for 2 datasets)&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-family:'Courier New,courier';">x,+-&lt;/span>	x with symmetric errors (2 columns for single dataset)&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-family:'Courier New,courier';">y,+,-&lt;/span>	y with asymmetric errors (3 columns for dataset)&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-family:'Courier New,courier';">x[1:5],+,-&lt;/span>	x_1 to x_5, each with asymmetric errors (15 columns in total)&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-family:'Courier New,courier';">x y,+-&lt;/span>	x with no errors, y with symmetric errors (3 columns in total)&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Data types&lt;/span>&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A file can contain different types of data. This type is specified immediately after the dataset name in round brackets, e.g. "x(float)", "labels(text)" or "y(float),+-".&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Only numerical (use float, number or numeric) and text (using text or string) data are supported. If a text column has spaces it should be surrounded by quotation marks.&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">Comments&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">&lt;span style=" font-weight:400;">If any of the "&lt;/span>&lt;span style=" font-family:'Courier New,courier'; font-weight:400;">#&lt;/span>&lt;span style=" font-weight:400;">", "&lt;/span>&lt;span style=" font-family:'Courier New,courier'; font-weight:400;">!&lt;/span>&lt;span style=" font-weight:400;">", "&lt;/span>&lt;span style=" font-family:'Courier New,courier'; font-weight:400;">;&lt;/span>&lt;span style=" font-weight:400;">" or "&lt;/span>&lt;span style=" font-family:'Courier New,courier'; font-weight:400;">%&lt;/span>&lt;span style=" font-weight:400;">" characters are found without being inside quotation marks, the rest of a line is ignored. Use these characters to add comments to a file.&lt;/span>&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Further notes&lt;/span>&lt;/p>
+&lt;ol style="-qt-list-indent: 1;">&lt;li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Extra tabs or spaces between columns are ignored&lt;/li>
+&lt;li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Extra data at the end of a line are ignored&lt;/li>
+&lt;li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The text &lt;span style=" font-family:'Courier New,courier';">nan&lt;/span> or &lt;span style=" font-family:'Courier New,courier';">inf&lt;/span> translates to the usual numerical values. These values aren't plotted in a plot, giving a break in the line.&lt;/li>
+&lt;li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You can encode the descriptor describing the data in the file itself with a line &lt;span style=" font-family:'Courier New,courier';">descriptor XXX&lt;/span> before the data. Leave the descriptor blank in the import dialog if you do this. Multiple descriptors can be placed in the file to store multiple sets of data. &lt;/li>&lt;/ol>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;">&lt;/p>&lt;/body>&lt;/html></string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Close</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>clicked(QAbstractButton*)</signal>
+   <receiver>ImportHelpDialog</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
Index: utils/utilfuncs.py
===================================================================
--- utils/utilfuncs.py	(revision 918)
+++ utils/utilfuncs.py	(working copy)
@@ -55,6 +55,16 @@
     """Validate widget name is okay."""
     return dsname_re.match(name) is not None
 
+def escapeDatasetName(name):
+    """Make string into a valid dataset name."""
+    # replace invalid characters
+    out = re.sub('[^0-9A-Za-z]', '_', name)
+    # add underscores for leading numbers
+    if re.match('^[0-9]', out):
+        return '_' + out
+    else:
+        return out
+
 class WeakBoundMethod:
     """A weak reference to a bound method.
 
Index: document/datasets.py
===================================================================
--- document/datasets.py	(revision 918)
+++ document/datasets.py	(working copy)
@@ -90,22 +90,32 @@
     This class is used to store a link filename with the descriptor
     '''
 
-    def __init__(self, filename, descriptor, useblocks=False):
+    def __init__(self, filename, descriptor, useblocks=False,
+                 prefix='', suffix='', ignoretext=False):
         '''Set up the linked file with the descriptor given.'''
         self.filename = filename
         self.descriptor = descriptor
         self.useblocks = useblocks
+        self.prefix = prefix
+        self.suffix = suffix
+        self.ignoretext = ignoretext
 
     def saveToFile(self, file):
         '''Save the link to the document file.'''
 
         params = [ repr(self.filename),
                    repr(self.descriptor),
-                   'linked=True' ]
+                   'linked=True',
+                   'ignoretext=%s' % repr(self.ignoretext)]
 
         if self.useblocks:
             params.append('useblocks=True')
 
+        if self.prefix:
+            params.append('prefix=%s' % repr(self.prefix))
+        if self.prefix:
+            params.append('suffix=%s' % repr(self.suffix))
+
         file.write('ImportFile(%s)\n' % (', '.join(params)))
 
     def reloadLinks(self, document):
Index: document/commandinterface.py
===================================================================
--- document/commandinterface.py	(revision 918)
+++ document/commandinterface.py	(working copy)
@@ -26,6 +26,8 @@
 external programs.
 """
 
+import numpy as N
+
 import veusz.qtall as qt4
 
 import datasets
@@ -356,7 +358,8 @@
         if self.verbose:
             print "Imported datasets %s" % (', '.join(datasetnames))
 
-    def ImportFile(self, filename, descriptor, useblocks=False, linked=False):
+    def ImportFile(self, filename, descriptor, useblocks=False, linked=False,
+                   prefix='', suffix='', ignoretext=False):
         """Read data from file with filename using descriptor.
         If linked is True, the data won't be saved in a saved document,
         the data will be reread from the file.
@@ -365,6 +368,10 @@
         to split the data into blocks. Dataset names are appended with an
         underscore and the block number (starting from 1).
 
+        If prefix is set, prefix is prepended to each dataset name
+        Suffix is added to each dataset name
+        ignoretext ignores lines of text in the file
+
         Returned is a tuple (datasets, errors)
          where datasets is a list of datasets read
          errors is a dict of the datasets with the number of errors while
@@ -372,7 +379,9 @@
         """
 
         op = operations.OperationDataImport(descriptor, filename=filename,
-                                            useblocks=useblocks, linked=linked)
+                                            useblocks=useblocks, linked=linked,
+                                            prefix=prefix, suffix=suffix,
+                                            ignoretext=ignoretext)
         dsnames = self.document.applyOperation(op)
         errors = op.simpleread.getInvalidConversions()
             
Index: document/operations.py
===================================================================
--- document/operations.py	(revision 918)
+++ document/operations.py	(working copy)
@@ -638,7 +638,8 @@
     descr = 'import data'
     
     def __init__(self, descriptor, useblocks=False, linked=False,
-                 filename=None, datastr=None):
+                 filename=None, datastr=None,
+                 prefix="", suffix="", ignoretext=False):
         """Setup operation.
         
         descriptor is descriptor for import
@@ -656,6 +657,9 @@
         self.linked = linked
         self.filename = filename
         self.datastr = datastr
+        self.prefix = prefix
+        self.suffix = suffix
+        self.ignoretext = ignoretext
         
     def do(self, document):
         """Import data.
@@ -673,13 +677,16 @@
         
         # do the import
         self.simpleread.clearState()
-        self.simpleread.readData(stream, useblocks=self.useblocks)
+        self.simpleread.readData(stream, useblocks=self.useblocks,
+                                 ignoretext=self.ignoretext)
         
         # associate file
         if self.linked:
             assert self.filename is not None
             LF = datasets.LinkedFile(self.filename, self.descriptor,
-                                     useblocks=self.useblocks)
+                                     useblocks=self.useblocks,
+                                     prefix=self.prefix, suffix=self.suffix,
+                                     ignoretext=self.ignoretext)
         else:
             LF = None
 
@@ -688,7 +695,9 @@
         self.olddatasets = dict(document.data)
         
         # actually set the data in the document
-        names = self.simpleread.setInDocument(document, linkedfile=LF)
+        names = self.simpleread.setInDocument(document, linkedfile=LF,
+                                              prefix=self.prefix,
+                                              suffix=self.suffix)
         return names
         
     def undo(self, document):
Index: document/simpleread.py
===================================================================
--- document/simpleread.py	(revision 918)
+++ document/simpleread.py	(working copy)
@@ -70,6 +70,9 @@
 $
 ''', re.VERBOSE )
 
+# a line starting with text
+text_start_re = re.compile( r'^[A-Za-z]' )
+
 # convert data type strings in descriptor to internal datatype
 datatype_name_convert = {
     'float': 'float',
@@ -282,7 +285,9 @@
                 # add data into dataset
                 dataset.append(dat)
 
-    def setInDocument(self, thedatasets, document, block=None, linkedfile=None):
+    def setInDocument(self, thedatasets, document, block=None,
+                      linkedfile=None,
+                      prefix='', suffix=''):
         """Set the read-in data in the document."""
 
         names = []
@@ -295,6 +300,7 @@
             if block is not None:
                 name += '_%i' % block
 
+            # does the dataset exist?
             if name+'\0DATA' in thedatasets:
                 vals = thedatasets[name+'\0DATA']
                 pos = neg = sym = None
@@ -316,8 +322,9 @@
                     ds = datasets.DatasetText( data=vals,
                                                linked = linkedfile )
 
-                document.setData( name, ds )
-                names.append(name)
+                finalname = prefix + name + suffix
+                document.setData( finalname, ds )
+                names.append(finalname)
             else:
                 break
 
@@ -423,7 +430,7 @@
 
         self.parts = [_DescriptorPart(p) for p in descriptor.split()]
 
-    def readData(self, stream, useblocks=False):
+    def readData(self, stream, useblocks=False, ignoretext=False):
         """Read in the data from the stream.
 
         If useblocks is True, data are read as separate blocks.
@@ -431,24 +438,31 @@
         number if set.
         """
 
+        self.ignoretext = ignoretext
         if useblocks:
-            self._readDataBlocked(stream)
+            self._readDataBlocked(stream, ignoretext)
         else:
-            self._readDataUnblocked(stream)
+            self._readDataUnblocked(stream, ignoretext)
 
-    def _readDataUnblocked(self, stream):
+    def _readDataUnblocked(self, stream, ignoretext):
         """Read in that data from the stream."""
 
         allparts = self.parts
 
         # loop over lines
         while stream.newLine():
-
             if stream.remainingline[:1] == ['descriptor']:
                 # a change descriptor statement
                 descriptor =  ' '.join(stream.remainingline[1:])
                 self._parseDescriptor(descriptor)
                 allparts += self.parts
+            elif ( self.ignoretext and len(stream.remainingline) > 0 and 
+                   text_start_re.match(stream.remainingline[0]) and
+                   len(self.parts) > 0 and
+                   self.parts[0].datatype != 'string' ):
+                # ignore the line if it is text and ignore text is on
+                # and first column is not text
+                pass
             else:
                 # normal text
                 for p in self.parts:
@@ -458,7 +472,7 @@
         self.parts = allparts
         self.blocks = None
 
-    def _readDataBlocked(self, stream):
+    def _readDataBlocked(self, stream, ignoretext):
         """Read in the data, using blocks."""
 
         blocks = {}
@@ -502,7 +516,8 @@
                 out[name[:-5]] = len(data)
         return out
 
-    def setInDocument(self, document, linkedfile=None):
+    def setInDocument(self, document, linkedfile=None,
+                      prefix='', suffix=''):
         """Set the data in the document.
 
         Returns list of variable names read.
@@ -515,10 +530,12 @@
             blocks = self.blocks
 
         names = []
-        for b in blocks:
-            for p in self.parts:
-                names += p.setInDocument(self.datasets, document,
-                                         block=b, linkedfile=linkedfile)
+        for block in blocks:
+            for part in self.parts:
+                names += part.setInDocument(self.datasets, document,
+                                            block=block,
+                                            linkedfile=linkedfile,
+                                            prefix=prefix, suffix=suffix)
 
         return names
 

_______________________________________________
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss

Répondre à