Intland's free requirements, development and test management hosting.
This server hosts 110,000+ users on the cloud!
Flexible parsing/formatting rules for text/csv drivers#52167/v5
more
Tags:  v1.1

Flexible parsing/formatting rules for text/csv drivers[TSK-52167]

Tracker: Tasks Priority: NormalNormal Owner: --
Assigned to: -- Submitted by: ejboy May 18, 2012 13:16 Status: --
Start Date: -- End Date: -- Estimated Hours: --
Spent Effort: -- % Spent / Plan: -- Category: --
Severity: --
Relations
Loading...
Description
Note: Previous issue You must login to see this link. Register now, if you have no user account yet. was removed.

Formatting syntax [Draft]:

format.<column_name>.<format_property>=<value>
where format_property can be one of:
  • trim = true|false
  • type = number|date|time + (timestamp or custom class name)
  • pattern. Depends on type:
    • for date/time - See SimpleDateFormat rules
    • for number - See DecimalFormat
    • for timestamp - N/A
  • locale
  • ...

Column_name should be case-insensitive.

Details
Comments & Attachments (2)
Associations (0)
Children (1)
References (0)
SCM Commits (8)
All (8)

Filter
Submitted Comment
ejboy
Jul 31, 2012 08:17
It turned out SimpleDateFormat cannot handle Timestamp format properly. Timestamp will be added as a separate format type. As a part of this work, a factory for instantiating formats based on type/pattern should be extracted. Add pad=left/right pad_char properties.

The following test reproduces the problem:

    public void testTimestampFormat() throws ParseException {
        PropertyFormat ci = new PropertyFormat();
        ci.setType("date");
        ci.setPattern("ddMMyy");
        ci.setLocale(Locale.US);

        Date d = simpleDateFormat.parse("01012012");
        assertEquals("010112", ci.format(d));
        assertEquals(d, ci.parse("010112"));

        ci = new PropertyFormat();
        ci.setType("date");
        ci.setPattern("yyyy-MM-dd HH:mm:ss:SSS");
//        ci.setLocale(Locale.US);

        d = new SimpleDateFormat("ddMMyy HH mm ss SSS").parse("05022012 17 00 34 427");
        assertEquals(d, ci.parse("2012-02-05 17:00:34.427000000"));

    }
ejboy
Jul 08, 2012 17:25
The work is mostly done locally. I've decided to deprecate trim property as it is too ambiguous. Instead format.trim(default=false) should be used for formatting/parsing values of columns and "trim_lines"(default=true) should be used for trimming of lines in CSV and text. Warning should be shown for "trim" property with suggestions.