# right-aligned table from csv

I have a csv file formatted like this one:

"","head 1","head 2","head 3"
"count 1","23","24","25"
"percentage 1","23%","24%","25%"
"count 2","53","54","55"
"percentage 2","53%","54%","55%"


I'm using datatool package to convert csv to table. I want to format the table to right-align. But right-align only works when the csv is formatted like this one:
"row 2","23","24","25"

I know I can manually adjust the table to get what I need. But the csv file is dynamic (the csv file is generated by the system).

How can I get a right-aligned table, fix the csv source or fix the LaTeX?

This is my the sample LaTeX code:

\documentclass[a4paper]{article}

\usepackage[small,compact]{titlesec}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{palatino}

\usepackage{datatool}

\begin{document}

\section{CSV Test}

\begin{table}[htbp]
\centering
\DTLdisplaydb{csvtest}
\caption{CSV Table Test}
\end{table}

\end{document}


And the csv:

"","Head 1","Head 2"
"Count 1","15","99"
"","1.92\%","12.69\%"
"Count 2","33","353"
"","1.99\%","21.28\%"

-
How about making a script to pre-process your csv file? –  ℝaphink Apr 29 '11 at 8:11
Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. –  doncherry Apr 29 '11 at 8:47
Can you add a minimal document that shows what you've done that doesn't work? (The document should load only datatool, read in a minimal CSV file and attempt to format it the way you want.) –  Alan Munn Apr 29 '11 at 11:07
The answer section is for solutions to the question only. I moved the example code to the question. You can edit it to provide more information one posted. You can and should also use <pre>...</pre> HTML tags around non-TeX code like CSV instead of ...<br>. –  Martin Scharrer Apr 29 '11 at 14:30

\DTLloaddb{csvtest}{csvtest.csv}
\begin{table}[htbp]
\centering
\renewcommand{\dtlstringalign}{r}
\DTLdisplaydb{csvtest}
\caption{CSV Table Test}
\end{table}


The quoted entries are interpreted by datatool as strings, so you need to help the package by telling it how to align strings.

-