forked from mindspore-Ecosystem/mindspore
!736 Skip blank line for TextFileDataset
Merge pull request !736 from yanghaitao/yht_tftextfile_black_line
This commit is contained in:
commit
e6473f0765
|
@ -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) {
|
||||||
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;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
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.
|
||||||
|
|
Loading…
Reference in New Issue