Thanks for a great CSV parser!
Here's my feature request, I'll start with my use case:
I am parsing Dates in the format "Tue Oct 4 09:34:02 2005". This translates to "new ParseDate("E MMM dd HH:mm:ss yyyy")".
This would work fine on a machine with the locale set to English/US. However if the locale is set to something else (german in my case) you'll get parse exceptions because 'Tue' is not a day in german.
One would have the same problem if you wanted to parse a german date on a US/UK machine.
There are three solutions to this problem:
1) I write my own Processor that takes a Locale as additional argument(easy but custom solution)
2) I call Locale.setDefault(Locale.ENGLISH) and change it back after reading. However this is a global fix and may cause trouble if other code is running concurrently. Dirty.
3) The existing ParseDate gets a second optional parameter (Locale) which tells SuperCSV what Locale it should assume for the input data.
IMHO Locale support should be part of the library and added it possible.
If I have the time I'll write a patch for this issue.
I created a patch to add this feature, it includes a test case:
https://sourceforge.net/tracker/index.php?func=detail&aid=2656804&group_id=201724&atid=978709
thanks for the patch..
This was closed but never added! I'll put it in the next release.
We never ended up adding this in 2.0.0-beta-1, and while solution 3 seems fine, I think we should consider adding a locale preference to CsvPreference. That way all locale-dependent processors can make use of it. Unfortunately, cell processors currently have no access to the preferences - it might make sense to add the preferences to the CsvContext (which they do have access to), but this will also require a few changes.
I think local may be important in parsing decimal numbers and dates.
But for most processors, the preferecens are unimportant. Maybe those
two processors could take as an optional argument, the preferences,
and if present during the execution of the processor use said prefs..
-k
On Mon, Sep 17, 2012 at 10:18 AM, James Bassett
jamesbassett@users.sf.net wrote:
--
-Kasper
Added for 2.1.0 (finally!)
[r271]
Related
Commit: [r271]