This repository was archived by the owner on Jun 28, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +29
-25
lines changed Expand file tree Collapse file tree 6 files changed +29
-25
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Please join and contribute:
19
19
20
20
## Trunk
21
21
22
+ * fix: handle empty column names properly
22
23
* feat: enforce usage of columns with columns_duplicates_to_array
23
24
* fix: update error message with invalid column type
24
25
Original file line number Diff line number Diff line change @@ -1009,7 +1009,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
1009
1009
var recordLength = record . length ;
1010
1010
1011
1011
if ( columns === true ) {
1012
- if ( isRecordEmpty ( record ) ) {
1012
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
1013
1013
this . __resetRecord ( ) ;
1014
1014
1015
1015
return ;
@@ -1044,12 +1044,10 @@ var Parser = /*#__PURE__*/function (_Transform) {
1044
1044
}
1045
1045
}
1046
1046
1047
- if ( skip_lines_with_empty_values === true ) {
1048
- if ( isRecordEmpty ( record ) ) {
1049
- this . __resetRecord ( ) ;
1047
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
1048
+ this . __resetRecord ( ) ;
1050
1049
1051
- return ;
1052
- }
1050
+ return ;
1053
1051
}
1054
1052
1055
1053
if ( this . state . recordHasError === true ) {
Original file line number Diff line number Diff line change @@ -1009,7 +1009,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
1009
1009
var recordLength = record . length ;
1010
1010
1011
1011
if ( columns === true ) {
1012
- if ( isRecordEmpty ( record ) ) {
1012
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
1013
1013
this . __resetRecord ( ) ;
1014
1014
1015
1015
return ;
@@ -1044,12 +1044,10 @@ var Parser = /*#__PURE__*/function (_Transform) {
1044
1044
}
1045
1045
}
1046
1046
1047
- if ( skip_lines_with_empty_values === true ) {
1048
- if ( isRecordEmpty ( record ) ) {
1049
- this . __resetRecord ( ) ;
1047
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
1048
+ this . __resetRecord ( ) ;
1050
1049
1051
- return ;
1052
- }
1050
+ return ;
1053
1051
}
1054
1052
1055
1053
if ( this . state . recordHasError === true ) {
Original file line number Diff line number Diff line change @@ -901,7 +901,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
901
901
var recordLength = record . length ;
902
902
903
903
if ( columns === true ) {
904
- if ( isRecordEmpty ( record ) ) {
904
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
905
905
this . __resetRecord ( ) ;
906
906
907
907
return ;
@@ -936,12 +936,10 @@ var Parser = /*#__PURE__*/function (_Transform) {
936
936
}
937
937
}
938
938
939
- if ( skip_lines_with_empty_values === true ) {
940
- if ( isRecordEmpty ( record ) ) {
941
- this . __resetRecord ( ) ;
939
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
940
+ this . __resetRecord ( ) ;
942
941
943
- return ;
944
- }
942
+ return ;
945
943
}
946
944
947
945
if ( this . state . recordHasError === true ) {
Original file line number Diff line number Diff line change @@ -704,7 +704,6 @@ class Parser extends Transform {
704
704
if ( err !== undefined ) return err
705
705
}
706
706
}
707
-
708
707
const lappend = ltrim === false || this . state . quoting === true || this . state . field . length !== 0 || ! this . __isCharTrimable ( chr )
709
708
// rtrim in non quoting is handle in __onField
710
709
const rappend = rtrim === false || this . state . wasQuoting === false
@@ -761,7 +760,7 @@ class Parser extends Transform {
761
760
// Convert the first line into column names
762
761
const recordLength = record . length
763
762
if ( columns === true ) {
764
- if ( isRecordEmpty ( record ) ) {
763
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
765
764
this . __resetRecord ( )
766
765
return
767
766
}
@@ -802,11 +801,9 @@ class Parser extends Transform {
802
801
if ( finalErr ) return finalErr
803
802
}
804
803
}
805
- if ( skip_lines_with_empty_values === true ) {
806
- if ( isRecordEmpty ( record ) ) {
807
- this . __resetRecord ( )
808
- return
809
- }
804
+ if ( skip_lines_with_empty_values === true && isRecordEmpty ( record ) ) {
805
+ this . __resetRecord ( )
806
+ return
810
807
}
811
808
if ( this . state . recordHasError === true ) {
812
809
this . __resetRecord ( )
Original file line number Diff line number Diff line change @@ -76,6 +76,18 @@ describe 'Option `columns`', ->
76
76
{a : ' 7' , b : ' 6' , c : ' 8' }
77
77
] unless err
78
78
next err
79
+
80
+ it ' lines with empty column names' , (next ) ->
81
+ parse '''
82
+ ,,,
83
+ 1,2,3,4
84
+ 5,6,7,8
85
+ ''' , columns : true , (err , data ) ->
86
+ data .should .eql [
87
+ {' ' : ' 4' }
88
+ {' ' : ' 8' }
89
+ ] unless err
90
+ next err
79
91
80
92
describe ' boolean' , ->
81
93
You can’t perform that action at this time.
0 commit comments