On Mon, 22 Nov 2021, Allin Cottrell wrote:
On Sat, 20 Nov 2021, Riccardo (Jack) Lucchetti wrote:
> On Fri, 19 Nov 2021, Cottrell, Allin wrote:
>
>> Well, my reluctance was based on the supposition that in maybe 99+% of
>> cases libgretl would know what separator to use better than most users.
>> I've now added '|' as one of the options libgretl should consider,
and in
>> my testing pipe-separated fields work fine. I'm willing to reconsider, but
>> I'd be surprised if anyone can come up with a real-world case where gretl
>> (now) gets it wrong.
>
> And I would too. All I'm saying is, why not give the user the option to use
> the automatic algorithm (as default) or force the delimiter choice for the
> remaining 1% of the cases?
Feel free to create a branch and implement that. I won't stand in the way if
the team reckons it's worthwhile.
Update: after inspecting the code, I found that what I had set out to
implement is already there, except with a different twist. The "csv_delim"
setting also affects csv reading: first, the currently set delimiter is
tried, and we revert to the automatic heuristic algorithm on failure. This
is not 100% complete, since it leaves out cases when the column separator
is not one of the traditional ones (comma, space, etc), but I can
personally live with that quite happily (I have no plan to save LaTeX
tabulars as CSV files).
Instead, I ended up making a very slight change (now in git) that makes
gretl a little more tolerant with malformed CSV files. Until now, we
aborted CSV import if we found a line where the number of fields was
different from the one we had previously calculated. After the change, we
only abort if we hit a line with MORE entries than the number of columns.
When the number of fields on a given CSV line is FEWER than necessary, we
now print out a warning and fill the missing entries with NAs.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------