Ignore:
Timestamp:
Jan 14, 2018 11:28:10 AM (4 years ago)
Author:
toby
Message:

fix histogram export file naming

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_csv.py

    r3140 r3223  
    206206        filenamelist = []
    207207        for hist in self.histnam:
    208             # multiple files: create a unique name from the histogram
    209             fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
    210             # create an instrument parameter file
     208            if len(self.histnam) == 1:
     209                name = self.filename
     210            else:    # multiple files: create a unique name from the histogram
     211                name = self.MakePWDRfilename(hist)
     212            fileroot = os.path.splitext(G2obj.MakeUniqueLabel(name,filenamelist))[0]
     213            # create the file
    211214            self.filename = os.path.join(self.dirname,fileroot + self.extension)
    212215            self.Writer(hist)
     
    230233
    231234    def Exporter(self,event=None):
    232         '''Export a set of powder data as a csv file
     235        '''Export a set of powder data as a single csv file
    233236        '''
    234237        # the export process starts here
     
    237240        self.loadTree()
    238241        if self.ExportSelect( # set export parameters
    239             AskFile='single' # get a file name/directory to save in
     242            AskFile='ask' # only one file is ever written
    240243            ): return
    241         filenamelist = []
    242244        csvData = []
    243245        headList = ["x",]
    244246        digitList = []
    245         fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(self.histnam[0]),filenamelist)
    246         # create a file
    247         self.filename = os.path.join(self.dirname,fileroot + self.extension)
     247        self.filename = os.path.join(self.dirname,os.path.splitext(self.filename)[0]
     248                                     + self.extension)
    248249        for ihst,hist in enumerate(self.histnam):
    249250            histblk = self.Histograms[hist]
     
    254255            digitList += [(13,3),]
    255256            csvData.append(histblk['Data'][1])
    256             print('Histogram '+hist+' written to file '+self.fullpath)
     257            print('Histogram '+hist+' added to file...')
    257258        self.OpenFile()
    258259        WriteList(self,headList)
     
    264265            self.Write(line)
    265266        self.CloseFile()
     267        print('...file '+self.fullpath+' written')
    266268
    267269class ExportPowderReflCSV(G2IO.ExportBaseclass):
Note: See TracChangeset for help on using the changeset viewer.