From dev@kurt @end|ng |rom v@nd|jck-|@ur|j@@en@be  Wed Mar 27 21:18:34 2019
From: dev@kurt @end|ng |rom v@nd|jck-|@ur|j@@en@be (Kurt Van Dijck)
Date: Wed, 27 Mar 2019 21:18:34 +0100
Subject: [Rd] [RFC] readtable enhancement
In-Reply-To: <658850e1-f344-2674-cc7c-c4b5d539eec5@gmail.com>
References: <1553274983-15970-1-git-send-email-dev.kurt@vandijck-laurijssen.be>
 <20190326185229.GA26161@x1.vandijck-laurijssen.be>
 <CAOQ5NyenGa23Nreqhmp-==9z5NXjEQ4LD99URC3BkqAeKHadnQ@mail.gmail.com>
 <20190326202007.GA29643@x1.vandijck-laurijssen.be>
 <658850e1-f344-2674-cc7c-c4b5d539eec5@gmail.com>
Message-ID: <20190327201834.GB2780@x1.vandijck-laurijssen.be>

Thank you for your answers.
I rather do not file a new bug, since what I coded isn't really a bug.

The problem I (my colleagues) have today is very stupid:
We read .csv files with a lot of columns, of which most contain
date-time stamps, coded in DD/MM/YYYY HH:MM.
This is not exotic, but the base library's readtable (and derivatives)
only accept date-times in a limited number of possible formats (which I
understand very well).

We could specify a format in a rather complicated format, for each
column individually, but this syntax is rather difficult to maintain.

My solution to this specific problem became trivial, yet generic
extension to read.table.
Rather than relying on the built-in type detection, I added a parameter
to a function that will be called for each to-be-type-probed column so I
can overrule the built-in limited default.
If nothing returns from the function, the built-in default is still
used.

This way, I could construct a type-probing function that is
straight-forward, not hard to code, and makes reading my .csv files
acceptible in terms of code (read.table parameters).

I'm sure I'm not the only one dealing with such needs, escpecially
date-time formats exist in enormous amounts, but I want to stress here
that my approach is agnostic to my specific problem.

For those asking to 'show me the code', I redirect to my 2nd patch,
where the tests have been extended with my specific problem.

What are your opinions about this?

Kind regards,
Kurt



[Rd] [RFC] readtable enhancement
Kurt Van Dijck