Merge pull request #18951 from taosdata/enh/td-21144
enh: ignore head line in cvs file
This commit is contained in:
commit
7cd76335fe
|
@ -1411,6 +1411,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
(*pNumOfRows) = 0;
|
||||
char* pLine = NULL;
|
||||
int64_t readLen = 0;
|
||||
bool firstLine = (pStmt->fileProcessing == false);
|
||||
pStmt->fileProcessing = false;
|
||||
while (TSDB_CODE_SUCCESS == code && (readLen = taosGetLineFile(pStmt->fp, &pLine)) != -1) {
|
||||
if (('\r' == pLine[readLen - 1]) || ('\n' == pLine[readLen - 1])) {
|
||||
|
@ -1418,6 +1419,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
}
|
||||
|
||||
if (readLen == 0) {
|
||||
firstLine = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1431,6 +1433,11 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
strtolower(pLine, pLine);
|
||||
const char* pRow = pLine;
|
||||
code = parseOneRow(pCxt, (const char**)&pRow, pDataBuf, &gotRow, &token);
|
||||
if (code && firstLine) {
|
||||
firstLine = false;
|
||||
code = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code && gotRow) {
|
||||
|
@ -1442,6 +1449,8 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
|
|||
pStmt->fileProcessing = true;
|
||||
break;
|
||||
}
|
||||
|
||||
firstLine = false;
|
||||
}
|
||||
taosMemoryFree(pLine);
|
||||
|
||||
|
|
Loading…
Reference in New Issue