3

I have a large CSV data set (240 rows - 4 columns ). When I try to embed the data using csvsimple the table overflows instead of flowing to the next page. How can I get the table to flow onto the next page, ideally repeating the initial header values for clarity?

\documentclass[a4paper]{article}
\usepackage{csvsimple}
\begin{document}
\section{Appendices}
    \subsection{Raw Data}
    \csvautotabular{data.csv}  
\end{document}

Where data.csv is:

Time ( s ),Voltage ( V ),Sound Level ( dBA ),Frequency
0,0.03,56,183.3333333
0.5,0.04,56,366.6666667
1,0.03,56,550
1.5,0.03,56,733.3333333
2,0.03,56,916.6666667
2.5,0.03,56,1100
3,0.03,56,1283.333333
3.5,0.03,74,1466.666667
4,0.04,93,1650
4.5,0.03,96,1833.333333
5,0.3,96,2016.666667
5.5,0.39,98,2200
6,0.94,99,2383.333333
6.5,0.35,100,2566.666667
7,1.47,100,2750
7.5,1.48,100,2933.333333
8,1.47,100,3116.666667
8.5,1,100,3300
9,1.06,100,3483.333333
9.5,1,100,3666.666667
10,1.15,100,3850
10.5,1.23,100,4033.333333
11,1.35,100,4216.666667
11.5,1.36,100,4400
12,1.35,100,4583.333333
12.5,1.38,100,4766.666667
13,1.39,100,4950
13.5,1.37,100,5133.333333
14,1.31,100,5316.666667
14.5,1.37,100,5500
15,1.37,100,5683.333333
15.5,1.38,100,5866.666667
16,1.38,100,6050
16.5,1.41,100,6233.333333
17,1.45,100,6416.666667
17.5,1.34,100,6600
18,1.44,100,6783.333333
18.5,1.3,100,6966.666667
19,1.45,100,7150
19.5,1.24,100,7333.333333
20,1.31,100,7516.666667
20.5,1.22,100,7700
21,1.21,100,7883.333333
21.5,1.05,100,8066.666667
22,1,100,8250
22.5,1.16,100,8433.333333
23,1.15,100,8616.666667
23.5,1.25,100,8800
24,1.22,100,8983.333333
24.5,1.26,100,9166.666667
25,1.27,100,9350
25.5,1.28,100,9533.333333
26,1.25,100,9716.666667
26.5,1.23,100,9900
27,1.29,100,10083.33333
27.5,1.29,100,10266.66667
28,1.37,100,10450
28.5,1.44,100,10633.33333
29,1.43,100,10816.66667
29.5,1.42,100,11000
30,1.43,100,11183.33333
30.5,1.34,100,11366.66667
31,1.38,100,11550
31.5,1.36,100,11733.33333
32,1.39,100,11916.66667
32.5,1.42,100,12100
33,1.47,100,12283.33333
33.5,1.47,100,12466.66667
34,1.43,100,12650
34.5,1.43,100,12833.33333
35,1.42,100,13016.66667
35.5,1.4,100,13200
36,1.42,100,13383.33333
36.5,1.42,100,13566.66667
37,1.4,100,13750
37.5,1.33,100,13933.33333
38,1.24,98,14116.66667
38.5,1.11,93,14300
39,1.16,93,14483.33333
39.5,1.11,93,14666.66667
40,0.75,95,14850
40.5,0.83,95,15033.33333
41,1.18,95,15216.66667
41.5,1.19,95,15400
42,1.19,94,15583.33333
42.5,1.18,94,15766.66667
43,1.2,93,15950
43.5,1.18,93,16133.33333
44,1.23,92,16316.66667
44.5,1.23,92,16500
45,1.24,92,16683.33333
45.5,1.24,92,16866.66667
46,1.25,92,17050
46.5,1.25,92,17233.33333
47,1.2,91,17416.66667
47.5,1.22,91,17600
48,1.14,90,17783.33333
48.5,0.39,88,17966.66667
49,0.2,88,18150
49.5,0.14,88,18333.33333
50,0.12,86,18516.66667
50.5,0.07,85,18700
51,0.11,84,18883.33333
51.5,0.08,84,19066.66667
52,0.08,84,19250
52.5,0.11,83,19433.33333
53,0.09,84,19616.66667
53.5,0.07,84,19800
54,0.05,84,19983.33333
54.5,0.03,84,20166.66667
55,0.03,85,20350
55.5,0.03,85,20533.33333
56,0.02,83,20716.66667
56.5,0.03,82,20900
57,0.03,82,21083.33333
57.5,0.03,83,21266.66667
58,0.03,82,21450
58.5,0.03,83,21633.33333
59,0.04,83,21816.66667
59.5,0.03,84,22000
60,0.04,84,22183.33333
60.5,0.02,83,22366.66667
61,0.03,83,22550
61.5,0.04,82,22733.33333
62,0.03,81,22916.66667
62.5,0.03,81,23100
63,0.03,80,23283.33333
63.5,0.03,80,23466.66667
64,0.03,81,23650
64.5,0.03,82,23833.33333
65,0.02,82,24016.66667
65.5,0.03,83,24200
66,0.03,84,24383.33333
66.5,0.03,83,24566.66667
67,0.03,84,24750
67.5,0.03,84,24933.33333
68,0.03,82,25116.66667
68.5,0.03,80,25300
69,0.03,79,25483.33333
69.5,0.02,78,25666.66667
70,0.04,79,25850
70.5,0.03,80,26033.33333
71,0.03,80,26216.66667
71.5,0.03,81,26400
72,0.03,81,26583.33333
72.5,0.02,81,26766.66667
73,0.03,81,26950
73.5,0.03,82,27133.33333
74,0.03,83,27316.66667
74.5,0.03,84,27500
75,0.03,85,27683.33333
75.5,0.03,85,27866.66667
76,0.03,85,28050
76.5,0.03,85,28233.33333
77,0.03,84,28416.66667
77.5,0.03,83,28600
78,0.03,81,28783.33333
78.5,0.02,79,28966.66667
79,0.02,76,29150
79.5,0.03,74,29333.33333
80,0.03,74,29516.66667
80.5,0.03,74,29700
81,0.03,77,29883.33333
81.5,0.04,79,30066.66667
82,0.03,80,30250
82.5,0.03,80,30433.33333
83,0.03,81,30616.66667
83.5,0.03,82,30800
84,0.03,82,30983.33333
84.5,0.03,82,31166.66667
85,0.03,82,31350
85.5,0.03,80,31533.33333
86,0.03,80,31716.66667
86.5,0.03,81,31900
87,0.03,83,32083.33333
87.5,0.03,84,32266.66667
88,0.03,85,32450
88.5,0.03,85,32633.33333
89,0.03,85,32816.66667
89.5,0.03,85,33000
90,0.03,85,33183.33333
90.5,0.03,85,33366.66667
91,0.03,85,33550
91.5,0.04,85,33733.33333
92,0.02,83,33916.66667
92.5,0.04,81,34100
93,0.04,79,34283.33333
93.5,0.03,79,34466.66667
94,0.03,78,34650
94.5,0.03,78,34833.33333
95,0.02,78,35016.66667
95.5,0.02,78,35200
96,0.03,78,35383.33333
96.5,0.03,77,35566.66667
97,0.03,76,35750
97.5,0.03,75,35933.33333
98,0.04,73,36116.66667
98.5,0.02,73,36300
99,0.03,73,36483.33333
99.5,0.02,70,36666.66667
100,0.03,71,36850
100.5,0.02,71,37033.33333
101,0.03,72,37216.66667
101.5,0.03,72,37400
102,0.03,72,37583.33333
102.5,0.03,73,37766.66667
103,0.03,72,37950
103.5,0.03,73,38133.33333
104,0.03,74,38316.66667
104.5,0.03,75,38500
105,0.03,75,38683.33333
105.5,0.02,76,38866.66667
106,0.03,76,39050
106.5,0.03,76,39233.33333
107,0.03,76,39416.66667
107.5,0.03,76,39600
108,0.03,76,39783.33333
108.5,0.02,76,39966.66667
109,0.03,76,40150
109.5,0.03,75,40333.33333
110,0.03,75,40516.66667
110.5,0.03,74,40700
111,0.03,74,40883.33333
111.5,0.03,74,41066.66667
112,0.03,73,41250
112.5,0.03,73,41433.33333
113,0.03,73,41616.66667
113.5,0.03,73,41800
114,0.04,72,41983.33333
114.5,0.03,72,42166.66667
115,0.03,72,42350
115.5,0.03,72,42533.33333
116,0.03,72,42716.66667
116.5,0.03,71,42900
117,0.03,72,43083.33333
117.5,0.03,72,43266.66667
118,0.03,75,43450
118.5,0.03,77,43633.33333
119,0.02,78,43816.66667
119.5,0.03,79,44000
120,0.03,78,44183.33333
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – jub0bs Aug 10 '14 at 14:24
  • @Jubobs Sorry for not adding the code earlier, not sure if I can/how to transmit actual CSV data, so I've included the amount of rows and columns in the question. - Cheers – Dragan Marjanovic Aug 10 '14 at 14:30
  • 1
    You should add a dummy CSV data set that reproduces the problem so people here can investigate the problem. – jub0bs Aug 10 '14 at 14:37
  • Much better :) You can have a look at our starter guide to familiarize yourself further with our format. – jub0bs Aug 10 '14 at 14:48
  • 2
    Have you tried \csvautolongtable, from p.8 of the csvsimple documentation? – Mike Renfro Aug 10 '14 at 22:45
2

Just to show another alternative with pgfplotstable.

\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\usepackage{longtable,siunitx}
\begin{filecontents*}{data.csv}
  Time ( s ),Voltage ( V ),Sound Level ( dBA ),Frequency
0,0.03,56,183.3333333
0.5,0.04,56,366.6666667
1,0.03,56,550
1.5,0.03,56,733.3333333
2,0.03,56,916.6666667
2.5,0.03,56,1100
3,0.03,56,1283.333333
3.5,0.03,74,1466.666667
4,0.04,93,1650
4.5,0.03,96,1833.333333
5,0.3,96,2016.666667
5.5,0.39,98,2200
6,0.94,99,2383.333333
6.5,0.35,100,2566.666667
7,1.47,100,2750
7.5,1.48,100,2933.333333
8,1.47,100,3116.666667
8.5,1,100,3300
9,1.06,100,3483.333333
9.5,1,100,3666.666667
10,1.15,100,3850
10.5,1.23,100,4033.333333
11,1.35,100,4216.666667
11.5,1.36,100,4400
12,1.35,100,4583.333333
12.5,1.38,100,4766.666667
13,1.39,100,4950
13.5,1.37,100,5133.333333
14,1.31,100,5316.666667
14.5,1.37,100,5500
15,1.37,100,5683.333333
15.5,1.38,100,5866.666667
16,1.38,100,6050
16.5,1.41,100,6233.333333
17,1.45,100,6416.666667
17.5,1.34,100,6600
18,1.44,100,6783.333333
18.5,1.3,100,6966.666667
19,1.45,100,7150
19.5,1.24,100,7333.333333
20,1.31,100,7516.666667
20.5,1.22,100,7700
21,1.21,100,7883.333333
21.5,1.05,100,8066.666667
22,1,100,8250
22.5,1.16,100,8433.333333
23,1.15,100,8616.666667
23.5,1.25,100,8800
24,1.22,100,8983.333333
24.5,1.26,100,9166.666667
25,1.27,100,9350
25.5,1.28,100,9533.333333
26,1.25,100,9716.666667
26.5,1.23,100,9900
27,1.29,100,10083.33333
27.5,1.29,100,10266.66667
28,1.37,100,10450
28.5,1.44,100,10633.33333
29,1.43,100,10816.66667
29.5,1.42,100,11000
30,1.43,100,11183.33333
30.5,1.34,100,11366.66667
31,1.38,100,11550
31.5,1.36,100,11733.33333
32,1.39,100,11916.66667
32.5,1.42,100,12100
33,1.47,100,12283.33333
33.5,1.47,100,12466.66667
34,1.43,100,12650
34.5,1.43,100,12833.33333
35,1.42,100,13016.66667
35.5,1.4,100,13200
36,1.42,100,13383.33333
36.5,1.42,100,13566.66667
37,1.4,100,13750
37.5,1.33,100,13933.33333
38,1.24,98,14116.66667
38.5,1.11,93,14300
39,1.16,93,14483.33333
39.5,1.11,93,14666.66667
40,0.75,95,14850
40.5,0.83,95,15033.33333
41,1.18,95,15216.66667
41.5,1.19,95,15400
42,1.19,94,15583.33333
42.5,1.18,94,15766.66667
43,1.2,93,15950
43.5,1.18,93,16133.33333
\end{filecontents*}
\begin{document}
\section{Appendices}
    \subsection{Raw Data}
    \pgfplotstableread[col sep=comma]{data.csv}\data
     \pgfplotstabletypeset[%
        begin table=\begin{longtable},
        every first row/.append style={before row={%
            Time (\si{\second}) & Voltage (\si{\volt}) & Sound Level (\si{dBA}) &
            Frequency (\si{\hertz})\\ \hline
        \endfirsthead%
            \multicolumn{4}{c}%
            {{\bfseries  Continued from previous page}} \\
            \hline
            Time (\si{\second}) & Voltage (\si{\volt}) & Sound Level (\si{dBA}) &
            Frequency (\si{\hertz})\\ \hline
        \endhead
            \hline \multicolumn{4}{|r|}{{Continued on next page}} \\ \hline
        \endfoot
            \hline
            \multicolumn{4}{|r|}{{Concluded}} \\ \hline
        \endlastfoot
        }},%
        end table=\end{longtable},
        %
        column type/.add={|}{},
        empty cells with={---}, %replace empty cells with ’--’
        %
        %every last column/.style={%
        %  column type/.add={}{|}},
        columns/Time ( s )/.style={column type=|l},
        columns/Voltage ( V )/.style={column type=|l},
        columns/Sound Level ( dBA )/.style={column type=|l},
        columns/Frequency/.style={column type=|l|},
        every head row/.style={%
        after row=\hline,output empty row},
        columns={Time ( s ),Voltage ( V ),Sound Level ( dBA ),Frequency},%
        /pgf/number format/fixed,
       /pgf/number format/precision=5,
]{\data}
\end{document}

enter image description here

This approach very flexible and you can customize your table as you want.

  • Slightly more complex, however, adds more options – Dragan Marjanovic Aug 17 '14 at 1:01

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.