提交 e6473f07 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!736 Skip blank line for TextFileDataset

Merge pull request !736 from yanghaitao/yht_tftextfile_black_line
...@@ -143,6 +143,9 @@ Status TextFileOp::LoadFile(const std::string &file, const int64_t start_offset, ...@@ -143,6 +143,9 @@ Status TextFileOp::LoadFile(const std::string &file, const int64_t start_offset,
std::unique_ptr<TensorQTable> tensor_table = std::make_unique<TensorQTable>(); std::unique_ptr<TensorQTable> tensor_table = std::make_unique<TensorQTable>();
while (getline(handle, line)) { while (getline(handle, line)) {
if (line.empty()) {
continue;
}
// If read to the end offset of this file, break. // If read to the end offset of this file, break.
if (rows_total >= end_offset) { if (rows_total >= end_offset) {
break; break;
...@@ -425,7 +428,9 @@ int64_t TextFileOp::CountTotalRows(const std::string &file) { ...@@ -425,7 +428,9 @@ int64_t TextFileOp::CountTotalRows(const std::string &file) {
std::string line; std::string line;
int64_t count = 0; int64_t count = 0;
while (getline(handle, line)) { while (getline(handle, line)) {
count++; if (!line.empty()) {
count++;
}
} }
return count; return count;
......
This is a text file. This is a text file.
Be happy every day. Be happy every day.
Good luck to everyone. Good luck to everyone.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册