Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class CsvSplitter extends AbstractTextSplitter {
String line
int z = 0

while( z++ < skipLines && reader.readLine()) { /* nope */ }
while( z++ < skipLines && reader.readLine() != null ) { /* nope */ }

if( firstLineAsHeader ) {
line = reader.readLine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ class CsvSplitterTest extends Specification {
items[0] == ['gamma', '', 'zeta']
items[1] == ['eta', 'theta', 'iota']
items[2] == ['mu', 'nu', 'xi']

when:
def LINES = '''
alpha,beta,delta

gamma,,zeta
eta,theta,iota
pi,rho,sigma
'''
.stripIndent().trim()
items = new CsvSplitter().target(LINES).options(skip:3).list()
then:
items.size() == 2
items[0] instanceof List
items[0] == ['eta', 'theta', 'iota']
items[1] == ['pi', 'rho', 'sigma']
}

def testSplitWithCount() {
Expand Down
Loading