Beispiel #1
0
    def clioindex(self):
	self.handles = self.getindexpid()
	storage = Storage(self.database)
	if self.handles:
            self.hquery = storage.formdatasetquery(self.handles,'')
            self.datainfo = storage.readdatasets(json.loads(self.hquery))
            self.csvio = StringIO(str(self.datainfo[0]['csvframe']))
            self.data = pd.read_csv(self.csvio, sep='\t', dtype='unicode',quoting=csv.QUOTE_NONE)
            self.columns = []
            for item in self.data.columns:
                self.col = re.sub(r"\"", "", item)
                self.columns.append(self.col)
            self.data.columns = self.columns
            self.storeddata = storage.readdatasets('')

        self.linking = {}
        for item in self.storeddata:
            try:
                self.linking[item['title']] = item['handle']
            except:
                skip = 'yes'
        self.data['handle'] = ''
        for row in self.data.index:
            title = self.data.ix[row]['Name']
	    uid = self.data.ix[row]['ID']
            try:
                self.data.ix[row]['handle'] = self.linking[title]
		self.links[uid] = self.linking[title]
            except:
                self.data.ix[row]['handle'] = ''
	self.data = self.data.drop('ID', axis=1)
        return self.data
Beispiel #2
0
    def retrievedatasets(self, handles):
	self.storeddata = {}
	storage = Storage(self.database)
	if handles:
            self.hquery = storage.formdatasetquery(handles,'')
            self.datainfo = storage.readdatasets(json.loads(self.hquery))
	    for self.item in self.datainfo:
                self.csvio = StringIO(str(self.item['csvframe']))
                self.data = pd.read_csv(self.csvio, sep='\t', dtype='unicode',quoting=csv.QUOTE_NONE)
                self.columns = []
                for itemcol in self.data.columns:
                    self.col = re.sub(r"\"", "", itemcol)
                    self.columns.append(self.col)
                self.data.columns = self.columns
		self.storeddata[self.item['handle']] = self.data
	return self.storeddata