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:
Extra }, or forgotten $. ...tNum & \Reference & \UnitPriceAtOneKUnits}
Missing $ inserted. ...tNum & \Reference & \UnitPriceAtOneKUnits}
Missing } inserted. ...tNum & \Reference & \UnitPriceAtOneKUnits}
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 the code that is currently not working:
\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
Any help would be appreciated.
Software Versions:
- TeXStudio 2.12.6
- MiKTeX 2.9.6350
- csvsimple 1.21
$
in your cvs file by\$
, i.e. add a backslash. A$
is a special character in LaTeX that starts/ends math mode.respect dollar
supposed to make it so you don't have to do that?\documentclass
and ends with\end{document}
.