예제 #1
0
 def write(self):
     """
         write all data
     """        
     try:
         precision = "float"
         if self.isDouble:
             precision = "double"
         self.__columnsAreWritable()
         f = open(self.filename, 'w')
         result = ''
         if self.header is not None :
             result += "".join(self.header)
         result += '#'
         for pointer in self.pointers : 
             result+=pointer.name+self.separator
         f.write(result[0:len(result)-1]+"\n")
         size = len(self.columns[0])
         
         for i in range(0, size):                
             values = [column[i] for column in self.columns]                
             size = len(values)          
             if isinstance(values[0],numpy.string_) is False:
                 f.write(self.separator.join([conv.getValue(el, precision) for el in values]))
             else:
                 f.write(self.separator.join(values))
             f.write("\n")              
         f.close()
     except Exception as e:
         print e
예제 #2
0
    def write(self):
        """
            write all data
        """
        try:
            precision = "float"
            if self.isDouble:
                precision = "double"
            self.__columnsAreWritable()
            f = open(self.filename, 'w')
            result = ''
            if self.header is not None:
                result += "".join(self.header)
            result += '#'
            for pointer in self.pointers:
                result += pointer.name + self.separator
            f.write(result[0:len(result) - 1] + "\n")
            size = len(self.columns[0])

            for i in range(0, size):
                values = [column[i] for column in self.columns]
                size = len(values)
                if isinstance(values[0], numpy.string_) is False:
                    f.write(
                        self.separator.join(
                            [conv.getValue(el, precision) for el in values]))
                else:
                    f.write(self.separator.join(values))
                f.write("\n")
            f.close()
        except Exception as e:
            print e
예제 #3
0
 def getTable(self):
     result = '<?xml version="1.0"?>'
     result += '<VOTABLE version="1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ivoa.net/xml/VOTable/v1.2">'+"\n"
     result += '<RESOURCE name="PdrExporter">'+"\n"
     result += '<TABLE name="results">'+"\n"
     
     for field in self.fields : 
         result += field.toString()+"\n"
         
     result += '<DATA>'+"\n"
     result += '<TABLEDATA>'+"\n"         
      
     columns_size = len(self.columns)
     data_size = len(self.columns[0])
     for i in range(0, data_size):        
         result += '<TR>'+"\n"            
         for j in range(0, columns_size):
             result += '<TD>'+str(conv.getValue(self.columns[j][i], self.fields[j].datatype))+'</TD>'+"\n"
         result += '</TR>'+"\n"
         
     result += '</TABLEDATA>'+"\n"
     result += '</DATA>'+"\n"
     
     result += '</TABLE>'+"\n"
     result += '</RESOURCE>'+"\n"
     
     result += '</VOTABLE>'
     return result        
예제 #4
0
 def test_double(self):        
     result = str(convert.getValue(1.0, cfg.doublePrecision))
     self.assertTrue(result == '1.000000000000000e+00')
예제 #5
0
 def test_float(self):        
     result = str(convert.getValue(1.0, cfg.floatPrecision))
     self.assertTrue(result == '1.000000e+00')