Extract the row addresses from the header information of the file
760255
private long[] getRowAddressesFromHeader( ByteBuffer header ) {
        /*
         * Jump over the no more needed first byte (used in readHeader to define the header size)
         */
        byte firstbyte = header.get();

        /* Read the data row addresses inside the file */
        long[] adrows = new long[fileWindow.getRows() + 1];
        if (firstbyte == 4) {
            for( int i = 0; i <= fileWindow.getRows(); i++ ) {
                adrows[i] = header.getInt();
            }
        } else if (firstbyte == 8) {
            for( int i = 0; i <= fileWindow.getRows(); i++ ) {
                adrows[i] = header.getLong();
            }
        } else {
            // problems
        }
        return adrows;
    }
645965
def _find_header_flat(self):
        
        nodes = self._node.contents.filter_tags(
                    matches=ftag('th'), recursive=False)
        if not nodes:
            return
        self._log('found header outside rows (%d <th> elements)' % len(nodes))
        return nodes
697926
def _get_headers(self):
        

        header = self.lines[0]
        self.lines = self.lines[1:]

        self.headers = \
            [self.clean(h) for h in header.split(self.seperator)]
        if self.is_strip:
            self.headers = self.headers[1:-1]
        return self.headers
999498
public ArrayList<String> getDataRows() {
		ArrayList<String> rows = new ArrayList<String>();
		for (String row : rowLookup.keySet()) {
			if (this.isMetaDataRow(row)) {
				continue;
			}
			HeaderInfo hi = rowLookup.get(row);
			if (!hi.isHide()) {
				rows.add(row);
			}
		}
		return rows;
	}
1072554
def _extract_header_value(line):
    

    # Skip blank lines, returning None
    if not line:
        return None

    # Attempt to split by equals sign
    halves = line.split('=')
    if len(halves) > 1:
        key = halves[0].strip()
        value = halves[1].strip()
        return {key: value}

    # Otherwise, attempt to split by colon
    else:
        halves = line.split(':')
        key = halves[0].strip()
        value = halves[1].strip()
        return {key: value}
167014
def _read_header(filename):
    
    with filename.open('rb') as f:
        h = f.read(HDR_LENGTH).decode()

        header = {}
        for line in h.split('\n'):
            if '=' in line:
                key, value = line.split(' = ')
                key = key.strip()[7:]
                value = value.strip()[:-1]
                header[key] = value

    return header
755558
def get_csv_col_headers(rows, row_headers_count_value=0):
    
    count = 0

    if rows:
        for row in rows:
            if exclude_empty_values(row[:row_headers_count_value]):
                break
            count += 1

    if len(rows) == count:
        count = 1  # by default

    return [r[row_headers_count_value:] for r in rows[:count]]
602516
def ParseRow(header,
             row):
  
  precondition.AssertDictType(row, Text, Text)

  result = rdf_osquery.OsqueryRow()
  for column in header.columns:
    result.values.append(row[column.name])
  return result
359558
def _read_header(filename):
    
    header = _read_header_text(filename)
    first_row = header[0]
    EXTRA_ROWS = 3  # drop DefaultValue1 LowRange1 HighRange1

    hdr = {}
    for group in finditer('(\w*)= ([\w.]*)', first_row):
        hdr[group.group(1)] = group.group(2)

    if first_row.startswith('BCI2000V'):
        VERSION = hdr['BCI2000V']

    else:
        VERSION = '1'
        hdr['DataFormat'] = 'int16'

    for row in header[1:]:
        if row.startswith('['):  # remove '[ ... Definition ]'
            section = row[2:-14].replace(' ', '')

            if section == 'StateVector':
                hdr[section] = []
            else:
                hdr[section] = {} # defaultdict(dict)
            continue

        if row == '':
            continue

        elif section == 'StateVector':
            statevector = {key: value for key, value in list(zip(STATEVECTOR, row.split(' ')))}
            hdr[section].append(statevector)

        else:
            group = match('(?P<subsection>[\w:%]*) (?P<format>\w*) (?P<key>\w*)= (?P<value>.*) // ', row)
            onerow = group.groupdict()

            values = onerow['value'].split(' ')
            if len(values) > EXTRA_ROWS:
                value = ' '.join(onerow['value'].split(' ')[:-EXTRA_ROWS])
            else:
                value = ' '.join(values)

            hdr[section][onerow['key']] = value  # similar to matlab's output

    return hdr
330209
def _parse_gene_coordinates(file):
        
        id_map = {}
        col = ['gene_curie', 'start', 'end', 'strand', 'build']
        if os.path.exists(os.path.join(os.path.dirname(__file__), file)):
            with open(os.path.join(os.path.dirname(__file__), file)) as tsvfile:
                reader = csv.reader(tsvfile, delimiter="\t")
                for row in reader:
                    id_map[row[col.index('gene_curie')]] = {
                        'start': row[col.index('start')],
                        'end': row[col.index('end')],
                        'strand': row[col.index('strand')],
                        'build': row[col.index('build')]
                    }
        return id_map
603835
def _parse_header(lines):
    
    header_count = _extract_header_number(lines)
    header_dict = {}
    for i in range(2, header_count + 2):
        pair = _extract_header_value(lines[i])

        if not pair:  # Ignore empty strings
            continue

        header_dict.update(pair)
    return header_dict
491013
def _parseSections(self, data, elfHeader):
        """"""
        offset = elfHeader.header.e_shoff
        shdrs = []
        for i in range(elfHeader.header.e_shnum):
            shdr = self.__classes.SHDR.from_buffer(data, offset)
            section_bytes = None
            ba_section_bytes = None
            if shdr.sh_type != SHT.NOBITS:
                section_bytes = (c_ubyte * shdr.sh_size).from_buffer(data, shdr.sh_offset)
                ba_section_bytes = bytearray(section_bytes)
            shdrs.append(ShdrData(name=None,header=shdr, raw=section_bytes, bytes=ba_section_bytes))
            offset += elfHeader.header.e_shentsize

        if elfHeader.header.e_shstrndx != SHN.UNDEF:
            strtab = shdrs[elfHeader.header.e_shstrndx]
            strtab_offset = strtab.header.sh_offset

            for section in shdrs:
                section.name = get_str(strtab.raw, section.header.sh_name)

        return shdrs
545742
def read_header(filename):
    '''  '''
    header = {}
    in_header = False
    data = nl.universal_read(filename)
    lines = [x.strip() for x in data.split('\n')]
    for line in lines:
        if line=="*** Header Start ***":
            in_header=True
            continue
        if line=="*** Header End ***":
            return header
        fields = line.split(": ")
        if len(fields)==2:
            header[fields[0]] = fields[1]
420776
def _tabulate(rows, headers, spacing=5):
    """"""
    if len(rows) == 0:
        return "None\n"
    assert len(rows[0]) == len(headers)
    count = len(rows[0])
    widths = [0 for _ in range(count)]
    rows = [headers] + rows

    for row in rows:
        for index, field in enumerate(row):
            if len(str(field)) > widths[index]:
                widths[index] = len(str(field))

    output = ""
    for row in rows:
        for index, field in enumerate(row):
            field = str(field)
            output += field + (widths[index] - len(field) + spacing) * " "
        output += "\n"
    return output
663644
def populate_csv_headers(rows,
                         partial_headers,
                         column_headers_count=1):
    

    result = [''] * (len(rows) - column_headers_count)

    for i_index in range(0, len(partial_headers)):
        for k_index in range(0, len(partial_headers[i_index])):

            # missing field find for a value in upper rows
            if not partial_headers[i_index][k_index] and i_index - 1 >= 0:

                # TODO: It's necesary a for or only taking the
                # inmediate latest row works well??
                for t_index in range(i_index - 1, -1, -1):
                    # TODO: could suposse that allways a value exists
                    partial_value = partial_headers[t_index][k_index]
                    if partial_value:
                        partial_headers[i_index][k_index] = partial_value
                        break

        result[i_index] = " ".join(map(str, partial_headers[i_index]))

    return result
1005235
def get_header_description(filedata):
    """"""
    python_version = sys.version_info.major
    if python_version == 3:
        filedata = Parser().parsestr(filedata)
    else:
        filedata = Parser().parsestr(filedata.encode("UTF-8", "replace"))

    payload = filedata.get_payload()
    lines = payload.split('\n')
    while True:
        if lines and lines[-1] == '':
            lines.pop()
        else:
            break
    return '\n'.join(lines)
1277584
def parse_headers(buff):
    
    preamble_lines = list(map(
        lambda x: six.u(x).decode(),
        iter(lambda: buff.readline().strip(), b''))
    )
    if not preamble_lines:
        raise EmptyBuffer()
    return preamble_lines[0], OrderedDict([l.split(':') for l in preamble_lines[1:]])