Closed twilco closed 6 years ago
I am able to reproduce this behavior. Oddly enough, using a File
instead of an InputStream
fixes the issue. This works:
import com.widen.tabitha.RowReaderFactory
RowReaderFactory.open(new File("SalesJan2009.csv")).get().withInlineHeaders().withCloseable { reader ->
def header = false
reader.forEach {
if (!header) {
header = true
println("header: " + it.header().get())
}
println("row: " + it)
}
}
This does not:
import com.widen.tabitha.RowReaderFactory
RowReaderFactory.open(new FileInputStream("SalesJan2009.csv")).get().withInlineHeaders().withCloseable { reader ->
def header = false
reader.forEach {
if (!header) {
header = true
println("header: " + it.header().get())
}
println("row: " + it)
}
}
Using the attached CSV and iterating through it with Tabitha (version 0.2.0), it appears to be starting halfway through the document rather than at the beginning. Here's my code:
This prints the following:
What Tabitha is registering as the header (the first row it has found) is actually line 526 in the CSV.
Turning this CSV into an XLSX via Microsoft Excel and then using that as the input to the code above works correctly (ignore the "empty" strings - I realize that's my problem and not a Tabitha problem):
CSV is attached as a
.txt
, as Github does not allow CSVs to be added as attachments.SalesJan2009.txt salesjan2009xl.xlsx