New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object cell reader should return null on empty string #84
Comments
Thanks for the report, I'll check that out. I have not test it for scala so it might be link to the types. |
did a quick test there and cannot reproduce on a simple java object, would you have the full stack trace with the line at which the npe was thrown? |
I try the following code import java.io.StringReader
import org.sfm.csv.CsvParser
object TestIssue84 {
class TestClass(var myField: String, var secondField: String)
def main(args: Array[String]) {
val it = CsvParser.mapTo(classOf[TestClass]).iterate(new StringReader("my_field,second_field\n,,"))
while(it.hasNext) { println(it.next.myField); println("X") }
}
} and it works fine. I'm not an expert in scala it seems you I needed to specify the type for second field. If I put Any I get a error as expected. I used the intellij plugin with the last scala jars |
just to check which version did you use? |
I think I reproduced it in 1.2.0 if that's the case the it's fixed in 1.3, can you confirm the version you are using? |
Thanks for looking into this. The example above was typed free hand and the stack trace was taken from the actual error I was having in my application. In the application the type was defined for the second field in the class. I pushed some test code up to my github with the settings I am using. After looking into this a bit further I believe the issue was that I was using Now that I've switched to
|
Thanks for that I'll add a ticket to better report the error, and change the date reader to return null for empty string. Hopefully I'll have that sorted by the end of the week. If you can't wait you can provide your own custom reader but you need to use the csv mapper factory directly. |
Great, thanks! |
I will be published the new version with jodatime and fixes soon, I think though that you probably will have to change the date format used. I added some doc on the wiki https://github.com/arnaudroger/SimpleFlatMapper/wiki/CsvParser#customised-date-format tell me if your stuck |
Excellent, thanks. Another question on the topic - with jOOQ you can use some wildcarding to specify the columns that should use a custom mapper. Is there similar support here? In other words, if I want to define that all columns matching the form
|
Not at the moment but it would be very difficult or had that or something similar |
The column definition is an case insensitive match right now |
@arnaudroger : This looks all very interesting. If you're interested in writing a guest blog post about using jOOQ+SimpleFlatMapper on blog.jooq.org (which is published also on DZone, JavaCodeGeeks, JAXenter and voxxed), let me know. This would certainly get you some additional traction. |
Thanks very much appreciated. I need to write something I have not come around it yet just will keep you posted |
Sure, any time you're ready |
very cool! I'll let you know if I have any issues. |
I will be in 1 4 1 should have it ready tomorrow |
141 is released |
When parsing rows that have adjacent commas, indicating a lack of value, the parser throws an error.
Note that I'm running this in Scala so not sure if that's impacting anything.
The text was updated successfully, but these errors were encountered: