# Only receiving the column titles when using csvsimple and \csvautotabular

I'm currently running into an issue where I'll only get the titles of my columns showing for my table when using csvsimple with \csvautotabular.

The current code I used to produce this is

    \documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}

\begin{document}
\csvautotabular[respect all]{test_utf8.csv}
\end{document}


I have used the test.csv

    Name,Battery %,Last updated
L1 A / B (C),5%,"Sept. 1, 2021, 00:00 a.m."
G D,12%,"Aug. 31, 2021, 9:09 a.m."
L2 E / F (G),80%,"Feb. 21, 2021, 10:00 a.m."


which I believe has the general formatting required for my other csv files.

Two changes solve the problem:

1. Changing \csvautotabular[respect all]{test_utf8.csv} to \csvautotabular[respect percent]{test_utf8.csv} (and other special characters that should be interpreted as normal characters).

2. Hiding commas which are not separators:

Name,Battery %,Last updated
L1 A  B (C),5%,{Sept. 1, 2021, 0000 a.m.}
G D,12%,{Aug. 31, 2021, 909 a.m.}
L2 E  F (G),80%,{Feb. 21, 2021, 1000 a.m.}


Because you need curly braces to mask a block that may contain commas not to be processed as separators, you shouldn't choose respect all.

• Thank you for the quick response. So besides the change of use for the respect function, it's just a formatting issue in the csv itself? Currently I'm pasting data into excel and removing what columns/rows I don't need and saving as .csv. There's probably a quick way to replace the quotation marks with curly braces before I save to import into TeX. Sep 1, 2021 at 6:52
• @JacksonWright Yes, commas were used in two functions. If you are expecting many commas in your data, you can choose another separator in CSV files by, say, [separator=semicolon] as an option to \csvautobooktabular. Sep 1, 2021 at 6:57
• @JacksonWright I have just corrected the wrong percent sings in my answer. They certainly should be commas. Sep 1, 2021 at 7:02
• Cheers, the hardest part now is just getting a program to save it with curly brackets instead of quote marks hahaha :) Sep 1, 2021 at 7:12
• @JacksonWright Or omitting quote marks with ; as a separator. Sep 1, 2021 at 7:21

I thought I would take this space to show off the recently added (v3.0 2021-08-08) capability of the readarray package to create tabulars. Because the file contains raw % tokens and uses quote grouping "...", I required a little more setup to digest it.

Basically, the \readdef macro places the contents of a file into a \def, while the \readarray macro places the contents of the \def into an array.

The \typesetarray macro is newly introduced, and uses helper macros named \typesetrowsepchar, \typesetcolsepchar (also \typesetplanesepchar for 3-D) to format the typeset, as they are inserted between rows, columns, and/or planes.

EDITED to place the catcode stuff in its own macro, easing the burden on invocation setup. Thus, the \readdef invocation is replaced with \readdefquotespercents in order to automatically digest raw % tokens as characters and to use quote-grouping.

RE-EDITED to use \lowercase magic to define the active character " inside of a macro.

\begin{filecontents*}[overwrite]{junk.dat}
Name,Battery %,Last updated
L1 A / B (C),5%,"Sept. 1, 2021, 00:00 a.m."
G D,12%,"Aug. 31, 2021, 9:09 a.m."
L2 E / F (G),80%,"Feb. 21, 2021, 10:00 a.m."
\end{filecontents*}
\documentclass{article}
\renewcommand\typesetrowsepchar{\\\hline}
\renewcommand\typesetcolsepchar{&}

\catcode\"=\active
\begingroup\lccode\~="
\lowercase{\endgroup\def~##1~}{{##1}}%
\catcode\%=12 \readdef{#1}#2\catcode\%=14
\catcode\"=12
\edef\tabdata{\tabdata}% CONVERT QUOTED PHRASES
}
\begin{document}