T-F-S / csvsimple

A LaTeX package for lightweight CSV file processing.
http://www.ctan.org/pkg/csvsimple
LaTeX Project Public License v1.3c
24 stars 5 forks source link

`collect data` doesn't collect `after first line` #28

Closed muzimuzhi closed 10 months ago

muzimuzhi commented 10 months ago

collect data collects both before line and after line, but only collects before first line and skips the symmetric after first line.

\begin{filecontents}[noheader,force]{data.csv}
a1,b1
a2,b2
a3,b3
\end{filecontents}

\documentclass{article}
\usepackage{csvsimple-l3}

\begin{document}
\csvreader[
  no head,
  collect data,
  before line=<before line>,
  before first line=<before 1st line>,
  after line=<after line>\par,
  after first line=<after 1st line>\par
]{data.csv}{}{%
  <\csvcoli><\csvcolii>%
}

\ttfamily
Expected:\par
<before 1st line><a1><b1><after 1st line>\par
<before line><a2><b2><after line>\par
<before line><a3><b3><after line>\par
\medskip

% Note the "after first line" code was used by \csvreader, not collected
Actual:\par
\csvdatacollection
\end{document}

image

Proposal

diff --git a/tex/latex/csvsimple/csvsimple-l3.sty b/tex/latex/csvsimple/csvsimple-l3.sty
index 87e48bd..2f9a704 100644
--- a/tex/latex/csvsimple/csvsimple-l3.sty
+++ b/tex/latex/csvsimple/csvsimple-l3.sty
@@ -967,6 +967,7 @@
 \cs_new_protected_nopar:Npn \__csvsim_collect_data:
   {
     \__csvsim_gset_tl_to_collect:N \g__csvsim_hook_after_head_tl
+    \__csvsim_gset_tl_to_collect:N \g__csvsim_hook_after_first_line_tl
     \__csvsim_gset_tl_to_collect:N \g__csvsim_hook_after_line_tl
     \__csvsim_gset_tl_to_collect:N \g__csvsim_hook_before_first_line_tl
     \__csvsim_gset_tl_to_collect:N \g__csvsim_hook_before_line_tl
T-F-S commented 10 months ago

Thank you for reporting this. Currently, I am very busy, but I will look into the matter in a few days.

T-F-S commented 10 months ago

I will correct this bug with the next version. Thank you.

T-F-S commented 10 months ago

Done with https://github.com/T-F-S/csvsimple/releases/tag/v2.5.0