mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
dbms: CSV format: development [#METR-19957].
This commit is contained in:
parent
dadadf1b37
commit
d72720616a
@ -24,7 +24,7 @@ CSVRowInputStream::CSVRowInputStream(ReadBuffer & istr_, const Block & sample_,
|
||||
}
|
||||
|
||||
|
||||
static void skipLineFeed(ReadBuffer & istr)
|
||||
static void skipEndOfLine(ReadBuffer & istr)
|
||||
{
|
||||
/// \n (Unix) или \r\n (DOS/Windows) или \n\r (Mac OS Classic)
|
||||
|
||||
@ -43,6 +43,8 @@ static void skipLineFeed(ReadBuffer & istr)
|
||||
throw Exception("Cannot parse CSV format: found \\r (CR) not followed by \\n (LF)."
|
||||
" Line must end by \\n (LF) or \\r\\n (CR LF) or \\n\\r.", ErrorCodes::INCORRECT_DATA);
|
||||
}
|
||||
else if (!istr.eof())
|
||||
throw Exception("Expected end of line", ErrorCodes::INCORRECT_DATA);
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +63,7 @@ static void skipDelimiter(ReadBuffer & istr, const char delimiter, bool is_last_
|
||||
return;
|
||||
}
|
||||
|
||||
skipLineFeed(istr);
|
||||
skipEndOfLine(istr);
|
||||
}
|
||||
else
|
||||
assertChar(delimiter, istr);
|
||||
@ -87,7 +89,7 @@ static void skipRow(ReadBuffer & istr, const char delimiter, size_t columns)
|
||||
readCSVString(tmp, istr);
|
||||
skipWhitespacesAndTabs(istr);
|
||||
|
||||
skipDelimiter(istr, i + 1 == columns, delimiter);
|
||||
skipDelimiter(istr, delimiter, i + 1 == columns);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +128,7 @@ bool CSVRowInputStream::read(Row & row)
|
||||
data_types[i]->deserializeTextCSV(row[i], istr, delimiter);
|
||||
skipWhitespacesAndTabs(istr);
|
||||
|
||||
skipDelimiter(istr, i + 1 == size, delimiter);
|
||||
skipDelimiter(istr, delimiter, i + 1 == size);
|
||||
}
|
||||
}
|
||||
catch (Exception & e)
|
||||
@ -372,7 +374,7 @@ bool CSVRowInputStream::parseRowAndPrintDiagnosticInfo(
|
||||
return false;
|
||||
}
|
||||
|
||||
skipLineFeed(istr);
|
||||
skipEndOfLine(istr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ void readCSVString(String & s, ReadBuffer & buf, const char delimiter)
|
||||
if (maybe_quote == delimiter)
|
||||
return;
|
||||
|
||||
if (maybe_quote == '\'' || maybe_quote == '\"')
|
||||
if (maybe_quote == '\'' || maybe_quote == '"')
|
||||
{
|
||||
++buf.position();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user