def _load_data(data_file, data_type):
raw_data = data_file.read()<EOL>if data_type is None:<EOL><INDENT>data_type = data_file.name.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL><DEDENT>data = []<EOL>if data_type == '<STR_LIT>':<EOL><INDENT>data = json.loads(raw_data)<EOL>return data<EOL><DEDENT>elif data_type == '<STR_LIT>':<EOL><INDENT>csv_data = StringIO(raw_data)<EOL>reader = csv.DictReader(csv_data, delimiter='<STR_LIT:U+002C>')<EOL>for line in reader:<EOL><INDENT>data.append(line)<EOL><DEDENT>return data<EOL><DEDENT>elif data_type in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>excel_data = StringIO(raw_data)<EOL>wb = openpyxl.load_workbook(excel_data)<EOL>ws = wb.active<EOL>headers = []<EOL>for row in ws.iter_rows(max_row=<NUM_LIT:1>):<EOL><INDENT>for cell in row:<EOL><INDENT>tmp = '<STR_LIT:_>'.join(cell.value.split("<STR_LIT:U+0020>")).lower()<EOL>headers.append(tmp)<EOL><DEDENT><DEDENT>for row in ws.iter_rows(row_offset=<NUM_LIT:1>):<EOL><INDENT>values = []<EOL>for cell in row:<EOL><INDENT>values.append(cell.value)<EOL><DEDENT>tmp = dict(zip(headers, values))<EOL>if len(values) == len(headers) and not row_empty(values):<EOL><INDENT>data.append(tmp)<EOL><DEDENT><DEDENT>return data<EOL><DEDENT>elif data_type == '<STR_LIT>':<EOL><INDENT>po = polib.pofile(raw_data)<EOL>for entry in po.untranslated_entries():<EOL><INDENT>data.append(entry.__dict__)<EOL><DEDENT>return data<EOL><DEDENT>elif data_type == '<STR_LIT>':<EOL><INDENT>lines = raw_data.split('<STR_LIT:\n>')<EOL>for l in lines:<EOL><INDENT>if l:<EOL><INDENT>var_id, string = l.split('<STR_LIT:=>')<EOL>tmp = dict(var_id=var_id, string=string)<EOL>data.append(tmp)<EOL><DEDENT><DEDENT>return data<EOL><DEDENT>else:<EOL><INDENT>return data<EOL><DEDENT>
Load data from CSV, JSON, Excel, ..., formats.