def post(self): # this is the main block of code # lets jazz # first - catch the passed file: if self.request.get("csv"): # datastore is clear ! # let's save new spreadsheet into it j = 0 new_data_source = self.request.get("csv") # remove all parasitic symbols from the source new_data_clear = new_data_source.replace ('\n', '') # next step is to split this Megastring into the lines: data_chunks = new_data_clear.splitlines() # and deeper split everyone into the words: for line in data_chunks: line = line.replace ('"', '') line = line.replace ('; ', '#%') data = line.split(";") # lets put chunks into datastore row = Placebo() row.developer = data[0] row.OID = data[1] row.concept = data[2] row.concept_words = Extract_Words(data[2]) row.category = data[3] row.category_words = Extract_Words(row.category) row.taxonomy = data[4] row.taxonomy_words = Extract_Words(row.taxonomy) row.taxonomy_version = data[5] row.code = data[6] row.descriptor = data[7].replace ('#%', '; ') row.put() j = j+1 logging.info('Putting '+str(j)+' rows') self.redirect('/')
def post(self): # this is the main block of code # lets jazz # first - catch the passed file: if self.request.get("csv"): # datastore is clear ! # let's save new spreadsheet into it j = 0 new_data_source = self.request.get("csv") # remove all parasitic symbols from the source new_data_clear = new_data_source.replace('\n', '') # next step is to split this Megastring into the lines: data_chunks = new_data_clear.splitlines() # and deeper split everyone into the words: for line in data_chunks: line = line.replace('"', '') line = line.replace('; ', '#%') data = line.split(";") # lets put chunks into datastore row = Placebo() row.developer = data[0] row.OID = data[1] row.concept = data[2] row.concept_words = Extract_Words(data[2]) row.category = data[3] row.category_words = Extract_Words(row.category) row.taxonomy = data[4] row.taxonomy_words = Extract_Words(row.taxonomy) row.taxonomy_version = data[5] row.code = data[6] row.descriptor = data[7].replace('#%', '; ') row.put() j = j + 1 logging.info('Putting ' + str(j) + ' rows') self.redirect('/')
def post(self): # this is the main block of code # lets jazz # first - catch the passed file: if self.request.get("csv"): j = 0 new_data_source = self.request.get("csv") # next step is split this file into lines: data_chunks = new_data_source.splitlines() # and deeper split everyone into words: for line in data_chunks: data = line.split(";") # lets put chunks into datastore row = Placebo() try: row.developer = data[0] except IndexError: # logging.info(data[0]+str(j)) pass try: row.OID = data[1] except IndexError: # logging.info(data[1]+str(j)) pass try: row.concept = data[2] except IndexError: # logging.info(data[2]+str(j)) pass try: row.category = data[3] except IndexError: # logging.info(data[3]+str(j)) pass try: row.taxonomy = data[4] except IndexError: # logging.info(data[4]+str(j)) pass try: row.taxonomy_version = data[5] except IndexError: # logging.info(data[5]+str(j)) pass try: row.code = data[6] except IndexError: # logging.info(data[6]+str(j)) pass try: row.descriptor = data[7] except IndexError: # logging.info(data[7]+str(j)) pass row.put() j = j+1 logging.info('Putting '+str(j)+' rows') # if j == 1904: # logging.info(data[1]) # greeting.avatar = db.Blob(avatar) # greeting.put() self.redirect('/nurce/')