Changeset 3872
- Timestamp:
- Apr 3, 2019 10:55:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r3867 r3872 6157 6157 def OnSaveSelSeq(event,csv=False,allcols=False): 6158 6158 '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 6159 6165 def WriteCSV(): 6160 6166 def WriteList(headerItems): … … 6166 6172 head = ['name'] 6167 6173 for col in cols: 6174 # Excel does not like unicode 6168 6175 item = G2obj.StripUnicode(G2frame.SeqTable.GetColLabelValue(col)) 6169 # get rid of labels that have Unicode characters6170 #if not all([ord(c) < 128 and ord(c) != 0 for c in item]): item = '?'6171 6176 if col in havesig: 6172 6177 head += [item,'esd-'+item] 6173 6178 else: 6174 6179 head += [item] 6175 SeqFile.write(WriteList(head)+'\n')6180 WriteLine(WriteList(head)+'\n') 6176 6181 for row,name in enumerate(saveNames): 6177 6182 line = '"'+saveNames[row]+'"' 6178 6183 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: 6181 6193 line += ','+str(saveData[col][row])+','+str(saveSigs[col][row]) 6182 except TypeError: 6183 line += ',0.0,0.0' 6184 else: 6185 try: 6194 else: 6186 6195 line += ','+str(saveData[col][row]) 6187 except TypeError: 6188 line += ',0.0' 6189 SeqFile.write(line+'\n') 6196 WriteLine(line+'\n') 6190 6197 def WriteSeq(): 6191 6198 lenName = len(saveNames[0]) … … 6197 6204 else: 6198 6205 line += ' %12s '%(item.center(12)) 6199 SeqFile.write(line+'\n')6206 WriteLine(line+'\n') 6200 6207 for row,name in enumerate(saveNames): 6201 6208 line = " '%s' "%(saveNames[row]) … … 6205 6212 line += ' %12.6f %12.6f '%(saveData[col][row],saveSigs[col][row]) 6206 6213 except TypeError: 6207 line += ' 0.0 0.0'6214 line += ' ' 6208 6215 else: 6209 6216 try: 6210 6217 line += ' %12.6f '%saveData[col][row] 6211 6218 except TypeError: 6212 line += ' 0.0'6213 SeqFile.write(line+'\n')6219 line += ' ' 6220 WriteLine(line+'\n') 6214 6221 6215 6222 # start of OnSaveSelSeq code … … 6220 6227 nrows = G2frame.SeqTable.GetNumberRows() 6221 6228 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 6225 6242 saveNames = [G2frame.SeqTable.GetRowLabelValue(r) for r in range(nrows)] 6226 6243 saveData = {}
Note: See TracChangeset
for help on using the changeset viewer.