I am both new here on stackexchange and fairly new to TeX.
I have tried searching for similar questions but found none.
I am working on a document where I need to pppulate a table from a csv file. The data should not be populated as is, but the number of values corresponding to each cell in the table (explained below). I have attached a picture showing the end result I want and a MWE showing the table (I don't know how to color the cells and get the labels "Konsekvens" and "Sannolikhet" in the right place without mixing up the formatting of the cells) and some example data that should result in the table in the picture.
For example for each 4,4 in the data set the upper right cell should increase, resulting in a 7 in that cell since there are 7 4,4.
The data is just example data so the table might differ slightly from the image.
A minor problem is that I can not get m{2cm}
to work in stead of p{2cm}
as shown here.
I have tried datatool but my only thought there was to use variables but using 16 variables feels like a complicated solution and I hope it can be done in a better way, and that's why I'm asking for help here.
\documentclass{article}
\usepackage{filecontents}
\usepackage{multirow}
\usepackage{graphicx}
\begin{filecontents*}{mycsvdata.csv}
Sannolikhet,Konsekvens
4,4
4,4
4,4
4,4
4,4
4,4
4,4
4,3
4,2
4,2
2,4
2,4
2,4
2,4
2,2
1,4
1,4
1,4
1,4
1,4
1,3
1,3
1,2
1,1
\end{filecontents*}
\begin{document}
\begin{tabular}{c|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
\cline{2-6}
\multirow{5}{*}{\rotatebox{90}{Konsekvens}}
& Mycket allvarlig&~&~&~&~ \\[0.5cm]\cline{2-6}
& Allvarlig&~&~&~&~ \\[0.5cm]\cline{2-6}
& Måttlig&~&~&~&~ \\[0.5cm]\cline{2-6}
& Försumbar&~&~&~&~ \\[0.5cm]\cline{2-6}
\multicolumn{1}{l}{}&~&Osannolik&Möjlig&Sannolikt&Mycket sannolikt \\\cline{3-6}
\multicolumn{6}{r}{Sannolikhet}
\end{tabular}
\end{document}