pyrqa/file_reader.py
def file_as_float_array(file_path, delimiter=',', column=0, offset=0):
        """
        Return file data as float array.

        :param file_path: Path to input file.
        :param delimiter: Column delimiter.
        :param column: Column to be extracted.
        :param offset: Number of leading input file lines that shall be ignored.
        :returns: Array of float values.
        :rtype: 1D array.
        """
        with open(file_path, 'r') as input_file:
            lines = input_file.readlines()
            if offset < len(lines):
                lines = lines[offset:]

            line_count = 0
            result = []
            for line in lines:
                splitted_line = line.strip().split(delimiter)
                if len(splitted_line) > column:
                    result.append(np.float32(splitted_line[column]))
                else:
                    line_count += 1
                    print "No element of index %d in line '%s'." % (column, line)

            if line_count:
                print "%d lines could not be processed." % line_count

            return np.array(result)

        Return file data as float array.

        :param file_path: Path to input file.
        :param delimiter: Column delimiter.
        :param column: Column to be extracted.
        :param offset: Number of leading input file lines that shall be ignored.
        :returns: Array of float values.
        :rtype: 1D array.
        
Return file data as float array.
Return file data as float array .
def file_as_float_array(file_path, delimiter=',', column=0, offset=0):
        with open(file_path, 'r') as input_file:
            lines = input_file.readlines()
            if offset < len(lines):
                lines = lines[offset:]
            line_count = 0
            result = []
            for line in lines:
                splitted_line = line.strip().split(delimiter)
                if len(splitted_line) > column:
                    result.append(np.float32(splitted_line[column]))
                else:
                    line_count += 1
                    print "No element of index %d in line '%s'." % (column, line)
            if line_count:
                print "%d lines could not be processed." % line_count
            return np.array(result)
def file_as_float_array ( file_path , delimiter = ',' , column = 0 , offset = 0 ) : with open ( file_path , 'r' ) as input_file : lines = input_file . readlines ( ) if offset < len ( lines ) : lines = lines [ offset : ] line_count = 0 result = [ ] for line in lines : splitted_line = line . strip ( ) . split ( delimiter ) if len ( splitted_line ) > column : result . append ( np . float32 ( splitted_line [ column ] ) ) else : line_count += 1 print "No element of index %d in line '%s'." % ( column , line ) if line_count : print "%d lines could not be processed." % line_count return np . array ( result )
Return file data as float array.
Return file data as float array .
"""
        Return file data as float array.

        :param file_path: Path to input file.
        :param delimiter: Column delimiter.
        :param column: Column to be extracted.
        :param offset: Number of leading input file lines that shall be ignored.
        :returns: Array of float values.
        :rtype: 1D array.
        """
Array of float values.
Array of float values .
1D array.
file_path
Path to input file.
Path to input file .
delimiter
None
column
Column to be extracted.
Column to be extracted .
offset
Number of leading input file lines that shall be ignored.
Number of leading input file lines that shall be ignored .