Changeset 3872


Ignore:
Timestamp:
Apr 3, 2019 10:55:09 PM (5 years ago)
Author:
toby
Message:

fix seq. listing w/empty cols; add column selection when not selected in table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3867 r3872  
    61576157    def OnSaveSelSeq(event,csv=False,allcols=False):
    61586158        'export the selected columns to a .txt or .csv file from menu command'
     6159        def WriteLine(line):
     6160            if '2' in platform.python_version_tuple()[0]:
     6161                SeqFile.write(G2obj.StripUnicode(line))
     6162            else:
     6163                SeqFile.write(line)
     6164               
    61596165        def WriteCSV():
    61606166            def WriteList(headerItems):
     
    61666172            head = ['name']
    61676173            for col in cols:
     6174                # Excel does not like unicode
    61686175                item = G2obj.StripUnicode(G2frame.SeqTable.GetColLabelValue(col))
    6169                 # get rid of labels that have Unicode characters
    6170                 #if not all([ord(c) < 128 and ord(c) != 0 for c in item]): item = '?'
    61716176                if col in havesig:
    61726177                    head += [item,'esd-'+item]
    61736178                else:
    61746179                    head += [item]
    6175             SeqFile.write(WriteList(head)+'\n')
     6180            WriteLine(WriteList(head)+'\n')
    61766181            for row,name in enumerate(saveNames):
    61776182                line = '"'+saveNames[row]+'"'
    61786183                for col in cols:
    6179                     if col in havesig:
    6180                         try:
     6184                    if saveData[col][row] is None:
     6185                        if col in havesig:
     6186#                            line += ',0.0,0.0'
     6187                            line += ',,'
     6188                        else:
     6189#                            line += ',0.0'
     6190                            line += ','
     6191                    else:
     6192                        if col in havesig:
    61816193                            line += ','+str(saveData[col][row])+','+str(saveSigs[col][row])
    6182                         except TypeError:
    6183                             line += ',0.0,0.0'
    6184                     else:
    6185                         try:
     6194                        else:   
    61866195                            line += ','+str(saveData[col][row])
    6187                         except TypeError:
    6188                             line += ',0.0'
    6189                 SeqFile.write(line+'\n')
     6196                WriteLine(line+'\n')
    61906197        def WriteSeq():
    61916198            lenName = len(saveNames[0])
     
    61976204                else:
    61986205                    line += ' %12s '%(item.center(12))
    6199             SeqFile.write(line+'\n')
     6206            WriteLine(line+'\n')
    62006207            for row,name in enumerate(saveNames):
    62016208                line = " '%s' "%(saveNames[row])
     
    62056212                            line += ' %12.6f %12.6f '%(saveData[col][row],saveSigs[col][row])
    62066213                        except TypeError:
    6207                             line += ' 0.0 0.0'
     6214                            line += '                           '
    62086215                    else:
    62096216                        try:
    62106217                            line += ' %12.6f '%saveData[col][row]
    62116218                        except TypeError:
    6212                             line += ' 0.0'
    6213                 SeqFile.write(line+'\n')
     6219                            line += '              '
     6220                WriteLine(line+'\n')
    62146221
    62156222        # start of OnSaveSelSeq code
     
    62206227        nrows = G2frame.SeqTable.GetNumberRows()
    62216228        if not cols:
    6222             G2frame.ErrorDialog('Select columns',
    6223                              'No columns selected in table. Click on column labels to select fields for output.')
    6224             return
     6229            choices = [G2frame.SeqTable.GetColLabelValue(r) for r in range(G2frame.SeqTable.GetNumberCols())]
     6230            dlg = G2G.G2MultiChoiceDialog(G2frame, 'Select columns to write',
     6231                'select columns',choices)
     6232            #dlg.SetSelections()
     6233            if dlg.ShowModal() == wx.ID_OK:
     6234                cols = dlg.GetSelections()
     6235                dlg.Destroy()
     6236            else:
     6237                dlg.Destroy()
     6238                return
     6239            #G2frame.ErrorDialog('Select columns',
     6240            #                 'No columns selected in table. Click on column labels to select fields for output.')
     6241            #return
    62256242        saveNames = [G2frame.SeqTable.GetRowLabelValue(r) for r in range(nrows)]
    62266243        saveData = {}
Note: See TracChangeset for help on using the changeset viewer.