def nadia_process_xls(filename, data_headers_location, data_values_location, y_axis_location, global_data_vector, global_const_vector, outfile): """Given an XLS file and all the settings -- such as where are headers, where is data, where is Y axis, etc. -- this function translates such XLS file in a sequence of JSON that match very closely the format of a CKAN package.""" sheet = open_sheet(filename) data = data_section(sheet, data_headers_location, data_values_location) y_axis(sheet, y_axis_location, data) data = remove_empty_lines(data) for name, location in global_data_vector: global_data(data, sheet, name, location) for name, value in global_const_vector: global_const(data, name, value) jsonize(data, outfile)
data[0].append("name") data[0].append("description") while i < len(M): y_row = M[i][0] i = i + 1 # XXX if not _is_garbage(data[i]): y_row = slugify(y_row) data[i].append(y_row) data[i].append("") last = i continue if last == -1: continue data[last][-1] += y_row def y_axis(sheet, range, data): M = row_values(sheet, range) for R in M: if len(R) != 1: raise ValueError if _is_garbage(data[1]): _y_axis_garbage_before_type(M, data) else: _y_axis_type_before_garbage(M, data) if __name__ == "__main__": sheet = open_sheet("test/sample1.xls") data = data_section(sheet, "C3:R6", "C7:R24") y_axis(sheet, "B7:B24", data) pprint.pprint(data)