提交 49bcb15f 编写于 作者: D dapan1121

enh: ignore head line in cvs file

上级 febb306a
...@@ -1411,6 +1411,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt, ...@@ -1411,6 +1411,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
(*pNumOfRows) = 0; (*pNumOfRows) = 0;
char* pLine = NULL; char* pLine = NULL;
int64_t readLen = 0; int64_t readLen = 0;
bool firstLine = (pStmt->fileProcessing == false);
pStmt->fileProcessing = false; pStmt->fileProcessing = false;
while (TSDB_CODE_SUCCESS == code && (readLen = taosGetLineFile(pStmt->fp, &pLine)) != -1) { while (TSDB_CODE_SUCCESS == code && (readLen = taosGetLineFile(pStmt->fp, &pLine)) != -1) {
if (('\r' == pLine[readLen - 1]) || ('\n' == pLine[readLen - 1])) { if (('\r' == pLine[readLen - 1]) || ('\n' == pLine[readLen - 1])) {
...@@ -1418,6 +1419,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt, ...@@ -1418,6 +1419,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
} }
if (readLen == 0) { if (readLen == 0) {
firstLine = false;
continue; continue;
} }
...@@ -1431,6 +1433,11 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt, ...@@ -1431,6 +1433,11 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
strtolower(pLine, pLine); strtolower(pLine, pLine);
const char* pRow = pLine; const char* pRow = pLine;
code = parseOneRow(pCxt, (const char**)&pRow, pDataBuf, &gotRow, &token); code = parseOneRow(pCxt, (const char**)&pRow, pDataBuf, &gotRow, &token);
if (code && firstLine) {
firstLine = false;
code = 0;
continue;
}
} }
if (TSDB_CODE_SUCCESS == code && gotRow) { if (TSDB_CODE_SUCCESS == code && gotRow) {
...@@ -1442,6 +1449,8 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt, ...@@ -1442,6 +1449,8 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt,
pStmt->fileProcessing = true; pStmt->fileProcessing = true;
break; break;
} }
firstLine = false;
} }
taosMemoryFree(pLine); taosMemoryFree(pLine);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册