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:





\section{CSV Test}

\caption{CSV Table Test}        


And the csv:

"","Head 1","Head 2"
"Count 1","15","99"
"Count 2","33","353"
  • How about making a script to pre-process your csv file?
    – raphink
    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>. Apr 29 '11 at 14:30
\caption{CSV Table Test}        

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

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.