0

I have a CSV document, similar to the one in the example code.

\documentclass[a4paper,12p]{article}

\usepackage[textwidth=450pt, textheight=680pt,top=3cm, left=2.5cm]{geometry} %margins

\usepackage{tabularx}
\usepackage{csvsimple}

\newcommand\mce{\multicolumn{1}{c}{}}
\newcounter{Rownumb}
\newcounter{Rownumbe}
\usepackage{siunitx}

\usepackage{ifthen}


\begin{filecontents*}{grade.csv}
option, descriptionb, description, pricel, pricer
1, {a is b, which}, f, 200, 300
0, b, g, 30, 244
1, c, {h, fdsf, dsfd}, 45, 222
1, d, j, 0, 455
FALSE, FALSE, k, 0, 344
\end{filecontents*}


\begin{document}

Example 2:\\
 \csvreader[tabular= >{\stepcounter{Rownumb}\theRownumb}r >{\everypar{\hangindent0.7cm}}p{3cm} b{1.5cm}, filter ifthen=\equal{\csvcoli}{1}]{grade.csv}{2=\dbo, 3=\deo,4=\pricel, 5=\pricer}{ & \textbf{\dbo} \deo & \mce    \\ \mce    && \$\,  \hfill \ifthenelse{\equal{\pricel}{0}}{}{\pricel,}\pricer \\ \mce}


Example 3:\\
 \csvreader[tabular= >{\stepcounter{Rownumbe}\theRownumbe}r >{\everypar{\hangindent0.7cm}}p{3cm} b{1.5cm}, filter ifthen=\NOT\equal{\opt}{FALSE}]{grade.csv}{1=\opt, 2=\dbo, 3=\deo,4=\pricel, 5=\pricer}{ & \textbf{\dbo} \deo & \mce    \\ \mce    && \$\,  \hfill \ifthenelse{\equal{\pricel}{0}}{}{\pricel,}\pricer \\ \mce}


\end{document}

In my real example, I have the CSV file created with an Excel file ({each cell's text }). Wherever there are commas (I found that out), I get these String/text symbols: " (highlighted in yellow) problem highlighted in yellow

Unfortunately, I don't get it with my sample code, I can add commas and don't get it. Which suggest that Excel must save it differently. Here is the example file: CSV example

Is there a code which I can use inside Excel to write commas? (I can \underline and \textbf{ to take effect in code) Using ; isn't really an option.

10
  • 2
    Welcome to TeX.SX! A minimal working example is supposed to be an example that demonstrates your problems and, as you say, your MWE does not. The unwanted quotation marks are clearly caused by the CSV files you are using. Can you post an example of the CSV output generated by excel? I don't see how anyone can help you unless you show us what is causing the problem. – user30471 Apr 7 '20 at 3:03
  • @Andrew: Yes, that is the frustrating bit. I wanted to minimise my example, so created a filecontent table in LaTex directly and found out that it doesn't do it. For Excel: I have the table, then go to 'Save As' and select CSV. – Chris Peh Apr 7 '20 at 3:22
  • Can you check whether the commas produced by Excel are ASCII characters, or something else? – user194703 Apr 7 '20 at 3:34
  • @Schrödinger's cat: How can I check this? – Chris Peh Apr 7 '20 at 3:35
  • 1
    @Schrödinger'scat -- Although the two "commas" in the T1 encoding have different codes, I believe (without having checked) that the non-ascii one is entered to LaTeX only through a macro as defined (for example) by a package like csquotes. The T1 encoding is a font encoding, and what is needed for the question here is an input encoding. – barbara beeton Apr 8 '20 at 0:23
0

Thank you @Schrödinger's cat and @ barbara beeton.

I have found a solution: If you use \newcommand{\comma}{, } in your preamble and then substitute all commas in Excel with \comma it works beautifully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.