Parse CSV line

@param line
line containing csv-encoded data
@return Array of values
975084
public static String[] parse(final String line) {
        boolean insideQuote = false;
        final ArrayList<String> result = new ArrayList<>();
        int quoteCount = 0;
        final StringBuilder sb = new StringBuilder();
        for (int i = 0; i < line.length(); i++) {
            final char c = line.charAt(i);

            if (c == QUOTE) {
                insideQuote = !insideQuote;
                quoteCount++;
            }

            if (c == COMMA && !insideQuote) {
                String value = sb.toString();
                value = unQuoteUnEscape(value);
                result.add(value);
                sb.setLength(0);
                continue;
            }

            sb.append(c);
        }

        result.add(sb.toString());

        // Validate
        if (quoteCount % 2 != 0) {
            return new String[0];
        }

        return result.toArray(new String[result.size()]);
    }
462692
public void parseTagedLine(String line) {
		String[] toks = line.split("(\\s|　| |\\t)+");
		words = new String[toks.length];
		tags = new String[toks.length];
		for(int i=0;i<toks.length;i++){
			String[] tt = toks[i].split("/");
			if(tt.length!=2)
				System.err.println("Wrong Format");
			words[i] = tt[0];
			tags[i]=tt[1];
		}
		
		
	}
1315760
private Entry parseEntry(String line) throws IOException {
    line = StringUtils.trimToEmpty(line);
    if (line.startsWith("#")) {
      return null;
    }

    int colonIndex = line.indexOf(":");
    if (colonIndex < 0) {
      return null;
    }

    String key = StringUtils.trimToNull(line.substring(0, colonIndex));
    if (key == null) {
      return null;
    }

    String rest = line.substring(colonIndex + 1, line.length());
    int hashIndex = rest.indexOf("#");

    String value = StringUtils.trimToEmpty(hashIndex >= 0 ? rest.substring(0, hashIndex) : rest);

    value = decode(value);

    return new Entry(line, key, value);
  }
1120490
private function findTableChars(string $line) : ?array
    {
        $lineChar  = $line[0];
        $spaceChar = null;

        for ($i = 0; $i < strlen($line); $i++) {
            if ($line[$i] === $lineChar) {
                continue;
            }

            if ($spaceChar === null) {
                $spaceChar = $line[$i];

                continue;
            }

            if ($line[$i] !== $spaceChar) {
                return null;
            }
        }

        if ($spaceChar === null) {
            return null;
        }

        return [$lineChar, $spaceChar];
    }
215139
protected function parse_line($line) {
        $data = array();
        foreach ($line as $keynum => $value) {
            if (!isset($this->columns[$keynum])) {
                // This should not happen.
                continue;
            }

            $key = $this->columns[$keynum];
            $data[$key] = $value;
        }
        return $data;
    }
71544
private function getFromConst($line)
    {
        $eq_pos = strpos($line, '=');
        $semicolon_pos = strrpos($line, ';');

        $constant_name = trim(substr($line, 6, $eq_pos - 6));
        $value = trim(substr($line, $eq_pos + 1, $semicolon_pos - $eq_pos - 1));

        return [$constant_name, $this->getNativeValueFromDefinition($value)];
    }
617513
static List<String> csvLines(Reader reader) {
        // This needs to handle quoted text that spans multiple lines,
        // so we divide the full text into chunks that correspond to
        // a single csv line
        try {
            BufferedReader br = new BufferedReader(reader);
            List<String> lines = new ArrayList<>();
            // The current line read from the Reader
            String line;
            // The full csv line that may span multiple lines
            String longLine = null;
            while ((line = br.readLine()) != null) {
                // If we have a line from the previous iteration,
                // we concatenate it
                if (longLine == null) {
                    longLine = line;
                } else {
                    longLine = longLine.concat("\n").concat(line);
                }
                // Count the number of quotes: if it's even, the csv line
                // must end here. If not, it will continue to the next
                if (isEvenQuotes(longLine)) {
                    lines.add(longLine);
                    longLine = null;
                }
            }
            // If there is text leftover, the line was not closed propertly.
            // XXX: we need to figure out how to handle errors like this
            if (longLine != null) {
                lines.add(longLine);
            }
            return lines;
        } catch(IOException ex) {
            throw new RuntimeException("Couldn't process data", ex);
        }
    }
654545
function(lines, param) {
              var csvLines = [];
              var left = "";
              while (lines.length) {
                var line = left + lines.shift();
                var row = rowSplit(line, param);
                if (row.closed) {
                  csvLines.push(row.cols);
                  left = "";
                } else {
                  left = line + (getEol(line, param) || "\n"); // if unable to getEol from data, assume "\n"
                }
              }
              return {lines: csvLines, partial: left};
            }
1363600
public static String[] parseListRecord(String line) {
        // return null if line is blank
        if (noLength(line)) {
            return null;
        }

        // trim away leading / trailing whitespace from list record
        line = line.trim();

        // remove list boundaries
        if (line.startsWith("{")) {
            line = line.substring(1);
        }
        if (line.endsWith("}")) {
            line = line.substring(0, line.length() - 1);
        }

        // return no fields if list record is empty
        if (line.trim().length() == 0) {
            return new String[0];
        }

        // split fields
        final CharacterIterator chit = new StringCharacterIterator(line);
        final List<String> fields = new ArrayList<String>();
        final StringBuilder fb = new StringBuilder();
        boolean inField = false;
        for (char c = chit.first(); c != CharacterIterator.DONE; c = chit
                .next()) {
            if (!inField && c == FIELD_BOUNDARY) {
                inField = true;
                fb.setLength(0);
            } else if (inField && c == FIELD_BOUNDARY) {
                int mark = chit.getIndex();
                char previousChar = chit.previous();
                if (previousChar == ESCAPE) {
                    fb.deleteCharAt(fb.length() - 1);
                    fb.append(c);
                } else {
                    inField = false;
                }
                chit.setIndex(mark);
            } else if (!inField && c == FIELD_SEPARATOR) {
                fields.add(fb.toString());
            } else if (inField) {
                fb.append(c);
            }
        }

        if (!line.endsWith(",")) {
            fields.add(fb.toString());
        }

        return fields.toArray(new String[fields.size()]);
    }
1249831
public IGPSObject parse(final String line) throws ParseException {
		try {
			final JSONObject json = new JSONObject(line);
			return this.parse(json);
		} catch (final JSONException e) {
			throw new ParseException("Parsing failed", e);
		}
	}
335397
protected boolean parseEmptyOrCommentLine(final ParserData parserData, final String line) {
        if (isBlankLine(line)) {
            if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) {
                parserData.getContentSpec().appendChild(new TextNode("\n"));
            } else {
                parserData.getCurrentLevel().appendChild(new TextNode("\n"));
            }
            return true;
        } else {
            if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) {
                parserData.getContentSpec().appendComment(line);
            } else {
                parserData.getCurrentLevel().appendComment(line);
            }
            return true;
        }
    }
1188292
public static List<Object> parseCSVLine(String line, String separatorChar) {
        String regex = // puts a doublequoted field in group(1) and an unquoted field into group(2)
                "\\G(?:^|" + separatorChar + ")" +
                "(?:" +
                "\"" +
                "((?:[^\"]++|\"\")*+)" +
                "\"" +
                "|" +
                "([^\"" + separatorChar + "]*)" +
                ")";
        Matcher mMain = Pattern.compile(regex).matcher("");
        Matcher mQuote = Pattern.compile("\"\"").matcher("");
        Matcher mDouble = Pattern.compile(DOUBLE_REGEX_WITH_NAN).matcher("");
        
        List<Object> values = new ArrayList<>();
        mMain.reset(line);
        while (mMain.find()) {
            Object value;
            if (mMain.start(2) >= 0) {
                String field = mMain.group(2);
                if (mDouble.reset(field).matches()) {
                    value = Double.parseDouble(field);
                } else {
                    value = field;
                }
            } else {
                // If quoted, always use string
                value = mQuote.reset(mMain.group(1)).replaceAll("\"");
            }
            values.add(value);
        }
        return values;
    }
780339
private Value parse(String line) {
        int i = line.indexOf(" : ");
        if (i == -1) {
            throw new IllegalArgumentException("Malformed line in RI Query "
                    + "result (expected ' : ' delimiter): '" + line + "'");
        } else {
            return NTriplesUtil.parseValue(line.substring(i + 3), factory);
        }
    }
1090716
def read_line(line):
        """"""
        name, value = '', ''

        if '=' in line:
            name, value = line.split('=', 1)

        return [name.strip(), value.strip()]
777899
def parse_line(self, line):
        """"""

        prefix = ""
        # ignore comma at start of lines
        if line.startswith(","):
            line, prefix = line[1:], ","

        j = json.loads(line)
        yield j
        self.io.write_line(prefix + json.dumps(j))
306570
def _parse_line(self, line):
        
        fields = line.split('|', 4)  # stop splitting after fourth | found
        line_info = {'raw_message': line}
        if len(fields) == 5:
            line_info.update(dict(zip(self._fieldnames, fields)))
        return line_info
823966
def parse_line(line):
  
  columns = line.split()
  token = columns.pop(0)
  values = [float(column) for column in columns]
  return token, values