Read current line from CSV file

@return array
175189
public function readLine()
    {
        $out = $this->read();
        if ($this->withHeader && is_array($out)) {
            $out = array_combine($this->header, $out);
        }
        return $out;
    }
1334872
public function getTail($lines = 10){
		$this->blockStart = $this->fileSize;
		$buff1 = Array();
		$lastLines = array();
		
		while($this->blockStart){
			$buff = $this->readChunk();
			if(!$buff)break;
			
			$lines -= substr_count($buff, "\n");
			
			if($lines <= 0)
			{
				$buff1[] = $this->cutHead($buff, "\n", abs($lines)+1);
				break;
			}
			$buff1[] = $buff;
		}
		
		for($i = count($buff1); $i >= 0; $i--){
			$lastLines = array_merge($lastLines, explode("\n", $buff1[$i]));
		}
		
		return $lastLines;
	}
110945
public function current() {
		if ($this->string === null) {
			$this->string = fgets($this->file);
		}
		
		$string = rtrim($this->string, "\n\r");
		
		if ($this->delimiter === null) {
			return $string;
		} 
		
		$dataRaw = explode($this->delimiter, $string);
		$data    = [];

		if ($this->partsNames === null) {
			foreach ($dataRaw as $key => $part) {
				$data[self::UNNAMED_PREFIX . $key] = $part;
			}
			
			return $data;
		}
		
		foreach ($dataRaw as $key => $part) {
			if (isset($this->partsNames[$key])) {
				$data[$this->partsNames[$key]] = $part;
				continue;
			}
			
			$data[self::UNNAMED_PREFIX . $key] = $part;
		}

		return $data;
	}
1074856
protected function getCurrentNodeRootline()
    {
        if ($this->currentNodeRootline === null) {
            $nodeRootline = $this->currentNode->getContext()->getNodesOnPath($this->currentNode->getContext()->getCurrentSiteNode()->getPath(), $this->currentNode->getPath());
            $this->currentNodeRootline = [];

            foreach ($nodeRootline as $rootlineElement) {
                $this->currentNodeRootline[$this->getNodeLevelInSite($rootlineElement)] = $rootlineElement;
            }
        }

        return $this->currentNodeRootline;
    }
1136547
public function current()
    {
        if ($this->header) {
            if (count($this->header) != count($this->currentData)) {
                throw new Error(
                    'CSV line has ' .
                    count($this->currentData) .
                    ' fields, but header has ' .
                    count($this->header) .
                    ' fields'
                );
            }
            $data = array_combine($this->header, $this->currentData);
            foreach ($this->formatters as $field => $callback) {
                foreach ($data as $k => &$v) {
                    if ($field == $k) {
                        $v = $callback($v);
                    } elseif (@preg_match($field, $k)) {
                        $v = $callback($v);
                    }
                }
            }

            return $data;
        }

        return $this->currentData;
    }
482567
public function next()
	{
		if( is_resource( $this->filePointer ) )
		{
			if( !feof( $this->filePointer ) )
			{
				$data = fgetcsv(
					$this->filePointer,
					self::$maxRowSize,
					$this->delimiter,
					$this->enclosure
				);
				//A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error. 
				if( count( $data ) == 1 && ( !isset( $data[0] ) || trim( $data[0] ) == '') ) 
					return $this->next();				
				if( $data )
				{
					$this->currentElement	= $data;	
					$this->rowCounter++;
					return TRUE;
				}
			}
		}
		return FALSE;
	}
440108
protected function fetchCSVRow()
    {
        if (!$this->fileHandle) {
            $this->openFile();
        }

        if (!$this->headerRow) {
            $this->fetchCSVHeader();
        }

        $this->rowNum++;

        $srcRow = fgetcsv(
            $this->fileHandle,
            0,
            $this->delimiter,
            $this->enclosure
        );

        if ($srcRow) {
            $row = array();

            foreach ($srcRow as $i => $value) {
                // Allow escaping of quotes and commas in the data
                $value = str_replace(
                    array('\\' . $this->enclosure,'\\' . $this->delimiter),
                    array($this->enclosure, $this->delimiter),
                    $value
                );
                // Trim leading tab
                // [SS-2017-007] Ensure all cells with leading [@=+] have a leading tab
                $value = ltrim($value, "\t");
                if (array_key_exists($i, $this->headerRow)) {
                    if ($this->headerRow[$i]) {
                        $row[$this->headerRow[$i]] = $value;
                    }
                } else {
                    user_error("No heading for column $i on row $this->rowNum", E_USER_WARNING);
                }
            }

            $this->currentRow = $row;
        } else {
            $this->closeFile();
        }

        return $this->currentRow;
    }
1219784
public function current()
	{
		$line = $this->file->current();
		if ($this->useFirstRecordAsHeader)
		{
			$header = $this->header;
			if (count($line) != count($header))
			{
				$size = min(count($header), count($line));
				$header = array_slice($this->header, 0, $size);
				$line = array_slice($line, 0, $size);
			}
			return array_combine($header, $line);
		}
		return $line;
	}
1159122
private function getCurrentValue()
    {
        $currentValue = $this->getFilter()->getCurrentValue();

        if (!is_array($currentValue)) {
            $currentValue = [];
        }

        if (!isset($currentValue['from']) || $currentValue['from'] === '') {
            $currentValue['from'] = $this->getMinValue();
        }

        if (!isset($currentValue['to']) || $currentValue['to'] === '') {
            $currentValue['to'] = $this->getMaxValue();
        }

        return $currentValue;
    }
140426
public function parse() {

		$lines = str_getcsv($this->source, $this->newline, $this->enclosure, $this->escape);

		// add keys from headline if available
		if ($this->getSourceHasHeadline()) {
			$keys = explode($this->delimiter, $lines[0]);
			$this->addKeys($keys);
			unset($lines[0]);
		}

		foreach ($lines as $line) { // iterate over all lines
			
			$values = str_getcsv($line, $this->delimiter, $this->enclosure, $this->escape); // save values in an array
			
			
			foreach ($values as $key => $value) {
				/* remove the escape character, because PHP doesn't do it
				 * https://bugs.php.net/bug.php?id=55413
				 */
				$values[$key] = str_replace($this->escape.$this->enclosure, $this->enclosure, $value);
				// trim all values if trimming is enabled
				if ($this->trim) {
					$values[$key] = trim($values[$key]);
				}
			}
			
			$dataset = array(); // create dataset
			foreach ($values as $position => $rawValue) { // iterate over all values
				$key = isset($this->keys[$position]) ? $this->keys[$position] : $position; // use the property number or a given key as index
				
				$processedValue = $rawValue;

				if (isset($this->modifiers[$key])) { // if there are registered modifiers for that key, let them do their work
					foreach ((array)$this->modifiers[$key] as $modifier) {
						$processedValue = call_user_func($modifier, $processedValue);
					}
				}
				
				$dataset[$key] = $processedValue;
			}

			$this->result[] = $dataset; // add dataset to the final result

		}
		return $this->result;
	}
649482
public function getIterator()
    {
        $csv = fopen($this->getConfig('file'), 'r');
        if ($csv === false) {
            throw new \RuntimeException('Unable to open file: ' . $this->getConfig('file'));
        }
        while (true) {
            $fields = fgetcsv(
                $csv,
                0,
                $this->getConfig('delimiter'),
                $this->getConfig('quote'),
                $this->getConfig('escape')
            );
            if ($fields === false) {
                break;
            }
            ++$this->line;
            if ($this->columns === null && $this->getConfig('header') === true) {
                $this->columns = array_map(function ($field) { return trim($field); }, $fields);
                if (count($this->columns) !== count(array_unique($this->columns))) {
                    throw new \RuntimeException(
                        'File does not have unique column headers: ' . $this->getConfig('file')
                    );
                }
            } else {
                $row = $this->getConfig('header') === true ? $this->map($fields) : $fields;
                yield empty($this->getConfig('callbacks')) === true ? $row : $this->callback($row);
            }
        }
        fclose($csv);
    }
905080
def get_current_line(self):
        """"""
        if not self.has_space():
            return None

        pos = self.pos - self.col
        string = self.string
        end = self.length

        output = []
        while pos < len(string) and string[pos] != '\n':
            output.append(string[pos])
            pos += 1
            if pos == end:
                break
        else:
            output.append(string[pos])

        if not output:
            return None

        return SourceLine(''.join(output), self.row)
986327
protected function readLine()
    {
        $buffer = '';

        while ($buffer === '') {
            if (($buffer = fgets($this->getFileHandler())) === false) {
                $this->currentLine = null;

                return;
            }
            $buffer = trim($buffer, "\n\r\0");

            if (!$this->skipEmptyLines) {
                break;
            }
        }

        $this->currentLine = $buffer;
    }
6414
public function fetch()
    {
        static $currentLine = 0;
        $dataResult = array();

        if (isset($this->options['skipHeader']) && $this->options['skipHeader'] === true) {
            $skipLines = 1;
        } elseif (isset($this->options['skipHeader']) && \is_numeric($this->options['skipHeader'])) {
            $skipLines = (int)$this->options['skipHeader'];
        } else {
            $skipLines = 0;
        }
        if (($handle = fopen($this->csvFilePath, 'r')) !== false) {
            while (($data = fgetcsv($handle, 65534, $this->csvDelimiter, $this->csvEnclosure)) !== false) {
                // skip header (maybe is better to set the first offset position instead)
                if ($currentLine < $skipLines) {
                    $currentLine++;
                    continue;
                }
                if ($currentLine >= $this->offset && $currentLine < ($this->offset + $this->limit)) {
                    if (isset($data[0]) && $data[0] !== '') {
                        $this->preProcessRecordData($data);
                        $dataResult[] = $data;
                    }
                }
                $currentLine++;
            }
            fclose($handle);
        }
        $this->logger->log(sprintf('%s: read %s lines and found %s records.', $this->csvFilePath, $currentLine, count($dataResult)), LOG_DEBUG);
        return $dataResult;
    }
427489
public function getIndexData() {
		if ($this->index === null) {
			$currentPointer = ftell($this->file);
			fseek($this->file, 0);
			
			$count       = 0;
			$this->index = [];
			
			while (fgets($this->file) !== false) {
				$this->index[++ $count] = ftell($this->file);
			}

			fseek($this->file, $currentPointer);
		}
		
		return $this->index;
	}
1226463
public function currentLine() {
        if (empty($this->EOF) || $this->char == 0) {
            return 1;
        }
        // Add one to $this->char because we want the number for the next
        // byte to be processed.
        return substr_count($this->data, "\n", 0, min($this->char, $this->EOF)) + 1;
    }
1061190
private function getLine()
    {
        if ($this->filePeek == null) {
            return fgets($this->fileHandle);
        }

        $ret = $this->filePeek;
        $this->filePeek = null;

        return $ret;
    }