def test_open_export(self): fp = refine.RefineProject(self.project.project_url()).export() line = fp.next() self.assertTrue('email' in line) for line in fp: self.assertTrue('M' in line or 'F' in line) fp.close()
def test_open_export_csv(self): fp = refine.RefineProject(self.project.project_url()).export() csv_fp = csv.reader(fp, dialect='excel-tab') row = csv_fp.next() self.assertTrue(row[0] == 'email') for row in csv_fp: self.assertTrue(row[3] == 'F' or row[3] == 'M') fp.close()
def compute_clusters(project_id, column, clusterer_type='binning', function=None, params=None): # returns a list of cluters of {'value';..., 'count':...} return refine.RefineProject(refine.RefineServer(), project_id).compute_clusters( column, clusterer_type, function, params)
def reconcile(project_id, column, service, reconciliation_type=None, reconciliation_config=None): return refine.RefineProject(refine.RefineServer(), project_id).reconcile(column, service, reconciliation_type, reconciliation_config)
def export_templating(project_id): # export templating: return a fileobject of a project's data return refine.RefineProject(refine.RefineServer(), project_id).export_templating( export_format='txt', engine='', prefix='', template='', rowSeparator='', suffix='')
def text_transform(project_id, column, expression, on_error='set-to-blank', repeat=False, repeat_count=10): return refine.RefineProject(refine.RefineServer(), project_id).text_transform( column, expression, on_error, repeat, repeat_count)
def split_column(project_id, column, separator=',', mode='separator', regex=False, guess_cell_type=True, remove_original_column=True): return refine.RefineProject(refine.RefineServer(), project_id).split_column( column, separator, mode, regex, guess_cell_type, remove_original_column)
def get_cell_value(project_id, columnIndex): # split break..... # nestedlist: [{u'cells': [{u'v': u'10136'},....{}]},{u 'cells': [...]}] # The cellIndex is an index for that column's data into the list returned from get_rows(). # 'from': cell_value, 'to': new_cell_value nested_list = refine.RefineProject(refine.RefineServer(), project_id).get_cell_value() AimCellValue = [] for inner_dicts in nested_list: AimCellValue.append(inner_dicts['cells'][columnIndex]) return AimCellValue
def transpose_columns_into_rows(project_id, start_column, column_count, combined_column_name, separator=':', prepend_column_name=True, ignore_blank_cells=True): return refine.RefineProject(refine.RefineServer(), project_id).transpose_columns_into_rows( start_column, column_count, combined_column_name, separator, prepend_column_name, ignore_blank_cells)
def get_split_cell_value(project_id, origin_column_length): nested_list = refine.RefineProject(refine.RefineServer(), project_id).get_cell_value() print(len(nested_list)) AimcellValue = [] counter = [] for inner_dicts in nested_list: if len(inner_dicts['cells']) > origin_column_length: counter.append( len(inner_dicts['cells']) - origin_column_length - 1) AimcellValue.append(inner_dicts['cells'][origin_column_length + 1:]) return counter, AimcellValue
def do_json(project_id, command, data): # do_json: issue a command to the server, parse & return encoded OR_JSON. return refine.RefineProject(refine.RefineServer(), project_id).do_json(command, data)
def do_raw(project_id, command, data): # do_raw : issue a command to the server & return a response object return refine.RefineProject(refine.RefineServer(), project_id).do_raw(command, data)
def project_url(project_id): # project_url return refine.RefineProject(refine.RefineServer(), project_id).project_url()
def project_name(project_id): # functions in RefineProject: # project_name return refine.RefineProject(refine.RefineServer(), project_id).project_name()
def get_operations(project_id): return refine.RefineProject(refine.RefineServer(), project_id).get_operations()
def flag_row(project_id, row, flagged=True): return refine.RefineProject(refine.RefineServer(), project_id).flag_row(row, flagged)
def reorder_columns(project_id, new_column_order): return refine.RefineProject(refine.RefineServer(), project_id).reorder_columns(new_column_order)
def annotate_one_row(project_id, row, annotation, state=True): return refine.RefineProject(refine.RefineServer(), project_id).annotate_one_row( row, annotation, state)
def get_single_cell_value(project_id, cellIndex, rowIndex): nested_list = refine.RefineProject(refine.RefineServer(), project_id).get_cell_value() aim_single_cell_value = nested_list[rowIndex]['cells'][cellIndex] return aim_single_cell_value
def transpose_rows_into_columns(project_id, column, row_count): return refine.RefineProject(refine.RefineServer(), project_id).transpose_rows_into_columns( column, row_count)
def fill_down(project_id, column): return refine.RefineProject(refine.RefineServer(), project_id).fill_down(column)
def blank_down(project_id, column): return refine.RefineProject(refine.RefineServer(), project_id).blank_down(column)
def move_column(project_id, column, index): return refine.RefineProject(refine.RefineServer(), project_id).move_column(column, index)
def get_models(project_id): # get_models: fill out column metadata. # Column structure is a list of columns in their order. # The cellIndex is an index for that column's data into the list returned from get_rows(). return refine.RefineProject(refine.RefineServer(), project_id).get_models()
def add_column(project_id, column, new_column, expression='value'): return refine.RefineProject(refine.RefineServer(), project_id).add_column(column, new_column, expression)
def rename_column(project_id, column, new_column): return refine.RefineProject(refine.RefineServer(), project_id).rename_column(column, new_column)
def get_reconciliation_services(project_id): return refine.RefineProject(refine.RefineServer(), project_id).get_reconciliation_services()
def get_reconciliation_service_by_name_or_url(project_id, name): return refine.RefineProject( refine.RefineServer(), project_id).get_reconciliation_service_by_name_or_url(name)
def guess_types_of_column(project_id, column, service): return refine.RefineProject(refine.RefineServer(), project_id).guess_types_of_column( column, service)
def star_row(project_id, row, starred=True): return refine.RefineProject(refine.RefineServer(), project_id).star_row(row, starred)