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

[Possible bug] Respect all/respect dollar commands seem to be ignored. #6

Closed techdude closed 3 years ago

techdude commented 5 years ago

I'm using csvsimple to import some columns from a csv file into a tabular environment. The CSV file contains a column where all the values are dollar amounts, so just including it directly gives errors like the following:

After reading through the manual for csvsimple, I found there are respect commands that should be able to be added. However it doesn't seem to respect either the respect dollar or respect all options. I've also tried respect dollar=true, respect all=true, /csv/respect dollar=true, and /csv/respect all=true. I don't mind if it respects all since I'm not planning on putting LaTeX in any of the fields - I just want it to display the data for the selected columns.

Here is a complete example showing the issue:

\documentclass[12pt,letterpaper,landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in,bottom=1in,top=1in]{geometry}
\usepackage{csvsimple}
\begin{document}
    \begin{table}[h]
    \begin{tabular}{c|l|l|l|r}%
        \bfseries Qty & \bfseries Part Description & \bfseries Manufacturer Part \# & \bfseries Reference & \bfseries Unit Price At 1K Units
        \csvreader[respect dollar,head to column names,separator=pipe]{BOM.csv}{}%
        {\\\hline\Qty & \PartDescription & \ManufacturerPartNum & \Reference & \UnitPriceAtOneKUnits}%
    \end{tabular}
\end{table}
\end{document}

Here is some sample data for the csv file (with only revelant columns):

Qty,PartDescription,ManufacturerPartNum,Reference,UnitPriceAtOneKUnits
5|Part 1|Option|Z1,Z2,Z3| $0.003
1|Part 2|Option|D1,D2,D3,D4| $0.004 
2|Part 3|Option|U1,U2,U3,U4| $0.008

Software Versions:

Note, this was also posted on SO, no solution was found, and they recommended submitting a bug report.

T-F-S commented 5 years ago

See my answer at StackExchange.