1

I have the following CSV dow_distribution.csv file:

dow,ANZ Volume,BHP Volume,CBA Volume,MQG Volume,NAB Volume,QAN Volume,RHC Volume,TLS Volume,WBC Volume,WOW Volume,AORD Volume,Total Volume
Monday,3.63,6.64,1.93,0.88,3.14,5.77,0.23,19.89,3.56,1.57,457.56,504.81
Tuesday,4.11,7.74,2.12,0.92,3.64,7.04,0.25,22.3,4.07,1.8,520.05,574.05
Wednesday,4.36,8.14,2.26,1.02,3.86,7.58,0.26,23.82,4.3,1.91,543.45,600.96
Thursday,4.56,8.32,2.46,1.07,4.22,7.3,0.25,24.05,4.44,2.05,547.04,605.76
Friday,2.47,4.61,1.36,0.63,2.22,3.76,0.13,13.38,2.33,1.02,292.65,324.58
Saturday,,,,,,,,,,,,0
Sunday,1.58,2.88,0.86,0.35,1.4,2.46,0.09,8.91,1.56,0.76,194.2,215.06

I want to process this into a table that fits onto the width of my page.

I've tried below - and have been reading the csvsimple package to rectify it but having difficulty doing so.

\documentclass[a4paper,14]{report}
\usepackage[utf8]{inputenc}      %  Commented out due to Cautionary error. 
\usepackage{csvsimple}
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }

\begin{document}

\csvautotabular{dow_distribution.csv}

\end{document}

Current Output: enter image description here

Desired Output:

Perhaps having a line break between the ticket names and the "Volume" might help shorten the width of the table (did it with MS paint), : enter image description here

If it doesn't all fit in one go, I would like it look like: enter image description here

1

The \csvautotabular macro is just for quick visualization. It it not intended to be used for productive code. Here, \csvreader or \csvloop allow customization.

I have two suggestions for your table.

The first one sets the table columns to a fixed width of 9mm which results in breaking the title automatically.

The second one rotates the long title texts by 90 degrees with help of the graphicx package and a small auxiliary macro \myrot.

\documentclass[a4paper,14]{report}
\usepackage[utf8]{inputenc}      %  Commented out due to Cautionary error.
\usepackage{csvsimple,graphicx}
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }

\def\myrot#1{\rotatebox{90}{\csname csvcol#1\endcsname\ }}

\begin{document}

{\small\tabcolsep1.4mm%
\csvreader[
  tabular=|r|*{12}{p{9mm}}|,
  nohead,column count=13,
  table head=\hline,
  late after first line=\\\hline,
  table foot=\hline]{dow_distribution.csv}%
{}%
{\csvlinetotablerow}
}

\bigskip

\csvreader[
  tabular=|r|*{12}{c}|,
  nohead,column count=13,
  table head=\hline,
  late after first line=\\\hline,
  table foot=\hline]{dow_distribution.csv}%
{}%
{\csviffirstrow{%
  \csvcoli & \myrot{ii} & \myrot{iii} & \myrot{iv} & \myrot{v} & \myrot{vi} & \myrot{vii}
  & \myrot{viii} & \myrot{ix} & \myrot{x} & \myrot{xi} & \myrot{xii} & \myrot{xiii}
}{\csvlinetotablerow}}

\end{document}

This gives:

enter image description here

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.