def read_array(filename):
    unused_, filetype = os.path.splitext(filename)
    fo = open(filename, "rU")
    try:
        if filetype == ".txt":
            header = map(eval, fo.readline().split("\t"))
            a = numpy.fromfile(fo, dtype="f8", sep="\n\t")
        elif filetype == ".csv":
            header = map(str.strip, fo.readline().split(","))
            a = numpy.fromiter(_ReadCSV(fo), numpy.float64)
        elif filetype == ".dat": # gnuplot style data
            line1 = fo.readline()[2:].split("\t")
            try:
                header = map(eval, line1)
            except (ValueError, SyntaxError): # assume no header line
                header = line1
                fo.seek(0)
            a = numpy.fromfile(fo, dtype="f8", sep="\n")
        else:
            raise ValueError(
                "read_array: Invalid file type. need .txt, .csv, or .dat (got %r)." % 
                filetype)
    finally:
        fo.close()
    # Data may have SCPI NAN or INF values in it. Convert to numpy
    # equivalents.
    a = numpy.fromiter(itertools.imap(check_value, a), numpy.float64)
    a.shape = (-1, len(header))
    return header, a
Builds a dictionary structure which defines the given macro.
dataset/ETHPy150Open kdart/pycopia/QA/pycopia/dataset.py/read_array--crossover with--dataset/ETHPy150Open nltk/nltk/nltk/tgrep.py/_macro_defn_action