PEATDB/Ekin/Base.py
def importCSV(self, filename=None, text=None, format=1, sep=',',
                  mode=None, truncate='end'):
        """
        Import csv file(s) to ekin data.
        This method should work without user intervention as much as possible.
        There are three options:
            1. Single file, curves per row, with ph values at the top
            2. Single file, curves per column, with ph values in
            the first column and curve names in first row
            3. Each curve in its own file, with 2 cols
        """
        import csv

        if filename != None:
            csvfile = open(filename)
            reader = csv.reader(csvfile, delimiter=sep)

        elif text != None:
            reader = csv.reader(text.split(os.linesep))

        x = reader.next()
        pts = len(x)
        print 'found csv data with %s points in header row' %pts
        datasets = {}
        for row in reader:
            if len(row)==0:
                continue
            name=row[0]; del row[0]
            xdata=x
            if len(row) < pts:
                print 'dataset is short %s points' %(pts-len(row))
                if truncate == 'end':
                    xdata = x[0:len(row)]
                else:
                    st=pts-len(row)
                    xdata = x[st:len(x)]
            elif len(row) > pts:
                row = row[0:pts]
                print 'dataset has more than %s points, truncating' %pts

            #datasets[name] = EkinConvert.xy2ekin([xdata,row])
	    datasets[name] = EkinDataset(xy=[xdata,row])
        for d in datasets.keys():
            self.insertDataset(datasets[d], d)
        print 'imported %s datasets' % len(datasets)
        print '-----------------------'
        return

        Import csv file(s) to ekin data.
        This method should work without user intervention as much as possible.
        There are three options:
            1. Single file, curves per row, with ph values at the top
            2. Single file, curves per column, with ph values in
            the first column and curve names in first row
            3. Each curve in its own file, with 2 cols
        
Import csv file(s) to ekin data.
This method should work without user intervention as much as possible.
There are three options:
1. Single file, curves per row, with ph values at the top
2. Single file, curves per column, with ph values in
the first column and curve names in first row
3. Each curve in its own file, with 2 cols
Import csv file ( s ) to ekin data . This method should work without user intervention as much as possible . There are three options : 1 . Single file curves per row with ph values at the top 2 . Single file curves per column with ph values in the first column and curve names in first row 3 . Each curve in its own file with 2 cols
def importCSV(self, filename=None, text=None, format=1, sep=',',
                  mode=None, truncate='end'):
        import csv
        if filename != None:
            csvfile = open(filename)
            reader = csv.reader(csvfile, delimiter=sep)
        elif text != None:
            reader = csv.reader(text.split(os.linesep))
        x = reader.next()
        pts = len(x)
        print 'found csv data with %s points in header row' %pts
        datasets = {}
        for row in reader:
            if len(row)==0:
                continue
            name=row[0]; del row[0]
            xdata=x
            if len(row) < pts:
                print 'dataset is short %s points' %(pts-len(row))
                if truncate == 'end':
                    xdata = x[0:len(row)]
                else:
                    st=pts-len(row)
                    xdata = x[st:len(x)]
            elif len(row) > pts:
                row = row[0:pts]
                print 'dataset has more than %s points, truncating' %pts
	    datasets[name] = EkinDataset(xy=[xdata,row])
        for d in datasets.keys():
            self.insertDataset(datasets[d], d)
        print 'imported %s datasets' % len(datasets)
        print '-----------------------'
        return
def importCSV ( self , filename = None , text = None , format = 1 , sep = ',' , mode = None , truncate = 'end' ) : import csv if filename != None : csvfile = open ( filename ) reader = csv . reader ( csvfile , delimiter = sep ) elif text != None : reader = csv . reader ( text . split ( os . linesep ) ) x = reader . next ( ) pts = len ( x ) print 'found csv data with %s points in header row' % pts datasets = { } for row in reader : if len ( row ) == 0 : continue name = row [ 0 ] ; del row [ 0 ] xdata = x if len ( row ) < pts : print 'dataset is short %s points' % ( pts - len ( row ) ) if truncate == 'end' : xdata = x [ 0 : len ( row ) ] else : st = pts - len ( row ) xdata = x [ st : len ( x ) ] elif len ( row ) > pts : row = row [ 0 : pts ] print 'dataset has more than %s points, truncating' % pts datasets [ name ] = EkinDataset ( xy = [ xdata , row ] ) for d in datasets . keys ( ) : self . insertDataset ( datasets [ d ] , d ) print 'imported %s datasets' % len ( datasets ) print '-----------------------' return
Import csv file(s) to ekin data.
Import csv file ( s ) to ekin data .
"""
        Import csv file(s) to ekin data.
        This method should work without user intervention as much as possible.
        There are three options:
            1. Single file, curves per row, with ph values at the top
            2. Single file, curves per column, with ph values in
            the first column and curve names in first row
            3. Each curve in its own file, with 2 cols
        """ #datasets[name] = EkinConvert.xy2ekin([xdata,row])
self
filename
text
format
sep
mode
truncate