[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#611967: csvtool: namedcol should retain heading row



tags 611967 + patch
thanks

"Kingsley G. Morse Jr." <kingsley@loaner.com> wrote:
> 
> I'm using it, and would like to suggest a modest
> improvement.
> 
> Please enhance the "namedcol" option to also
> return a first row of the names of the chosen
> columns.
> 
> For example
> 
>     $ csvtool namedcol Account,Cost input.csv > output.csv
> 
> might return
> 
>     Account,Cost
>     1,$5
>     2,$7
>     3,$3
> 
> At least for me, it omitted the heading row
> "Account,Cost".
> 

I agree that it could be a nice improvement. Please find attached
a patch that implements the described feature.

Regards,

-- 
Mehdi Dogguy
>From 6c251219c4240ec4f04b9be3c1c5a1558ed12aaa Mon Sep 17 00:00:00 2001
From: Mehdi Dogguy <mehdi@debian.org>
Date: Thu, 5 Jan 2012 03:10:43 +0100
Subject: [PATCH] Retain heading row when using namedcol

---
 debian/changelog           |    7 +++++++
 debian/patches/01_namedcol |   10 ++++++++++
 debian/patches/series      |    1 +
 3 files changed, 18 insertions(+), 0 deletions(-)
 create mode 100644 debian/patches/01_namedcol
 create mode 100644 debian/patches/series

diff --git a/debian/changelog b/debian/changelog
index ce57af8..225f7e5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ocaml-csv (1.2.2-2) unstable; urgency=low
+
+  * Retain heading row when using namedcol option (Closes: #611967).
+    - add debian/patches/01_namedcol
+
+ -- Mehdi Dogguy <mehdi@debian.org>  Thu, 05 Jan 2012 03:09:19 +0100
+
 ocaml-csv (1.2.2-1) unstable; urgency=low
 
   * New upstream release
diff --git a/debian/patches/01_namedcol b/debian/patches/01_namedcol
new file mode 100644
index 0000000..4c0f0fc
--- /dev/null
+++ b/debian/patches/01_namedcol
@@ -0,0 +1,10 @@
+--- a/examples/csvtool.ml
++++ b/examples/csvtool.ml
+@@ -164,6 +164,7 @@
+       let data = List.map (
+         fun row -> List.map (fun name -> List.assoc name row) names
+       ) data in
++      let data = names :: data in
+       Csv.output_all (Csv.to_channel ~separator:output_sep chan) data
+   ) files
+ 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..eb8876e
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+01_namedcol
-- 
1.7.7.3


Reply to: