Table is too large to fit within the textwidth - datatable

I am having a problem with fitting my huge table within a page.Here are the current output of my code
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}[H]
\centering
\begin{adjustbox}{width=\textwidth}
\begin{tabular}{|lllllllllllll|}
\hline
& \multicolumn{2}{l}{Li-ion Battery} & \multicolumn{2}{l}{Lead-Acid Battery} & \multicolumn{2}{l}{Redox Flow Battery} & \multicolumn{2}{l}{Sodium-Sulphur} & \multicolumn{2}{l}{Sodium Metal Halide} & \multicolumn{2}{l|}{Zinc-Hybrid Cathode} \\ \cline{2-13}
Parameter & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 \\ \hline
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Capital Cost - Energy \\ Capacity ()\end{tabular}} & 271 & \multicolumn{1}{l|}{(189)} & 260 & \multicolumn{1}{l|}{(220)} & 555 & \multicolumn{1}{l|}{(393)} & 661 & \multicolumn{1}{l|}{(465)} & 700 & \multicolumn{1}{l|}{(482)} & 265 & (393) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Power Conversion \\ System (PCS) ()\end{tabular}} & 288 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & (211) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Balance of Plant (BOP)\\ ()\end{tabular}} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & (95) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Construction and \\ Commisioning ()\end{tabular}} & 101 & \multicolumn{1}{l|}{(96)} & 176 & \multicolumn{1}{l|}{(167)} & 190 & \multicolumn{1}{l|}{(180)} & 133 & \multicolumn{1}{l|}{(127)} & 115 & \multicolumn{1}{l|}{(110)} & 173 & (164) \\ \hline
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Total Project Cost \\ ()\end{tabular}} & 1876 & \multicolumn{1}{l|}{(1446)} & 2194 & \multicolumn{1}{l|}{(1854)} & 3430 & \multicolumn{1}{l|}{(2598)} & 3626 & \multicolumn{1}{l|}{(2674)} & 3710 & \multicolumn{1}{l|}{(2674)} & 2202 & (1730) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Total Project Cost \\ ()\end{tabular}} & 469 & \multicolumn{1}{l|}{(362)} & 549 & \multicolumn{1}{l|}{(464)} & 858 & \multicolumn{1}{l|}{(650)} & 907 & \multicolumn{1}{l|}{(669)} & 928 & \multicolumn{1}{l|}{(669)} & 551 & (433) \\ \hline
\multicolumn{1}{|l|}{O\&M Fixed ()} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & (8) \\
\multicolumn{1}{|l|}{O\&M Variable ()} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}System Round-Trip \\ Efficiency\end{tabular}} & \multicolumn{2}{l|}{0.86} & \multicolumn{2}{l|}{0.72} & \multicolumn{2}{l|}{0.675} & \multicolumn{2}{l|}{0.75} & \multicolumn{2}{l|}{0.83} & \multicolumn{2}{l|}{0.72} \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Response time \\ (limited byPCS)\end{tabular}} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Cycles at 80\% Depth\\ of Discharge\end{tabular}} & \multicolumn{2}{l|}{3500} & \multicolumn{2}{l|}{900} & \multicolumn{2}{l|}{10000} & \multicolumn{2}{l|}{4000} & \multicolumn{2}{l|}{3500} & \multicolumn{2}{l|}{3500} \\
\multicolumn{1}{|l|}{Lifetime (Years)} & \multicolumn{2}{l|}{10} & \multicolumn{2}{l|}{2.6} & \multicolumn{2}{l|}{15} & \multicolumn{2}{l|}{13.5} & \multicolumn{2}{l|}{12.5} & \multicolumn{2}{l|}{10} \\
\multicolumn{1}{|l|}{MRL} & 9 & \multicolumn{1}{l|}{(10)} & 9 & \multicolumn{1}{l|}{(10)} & 8 & \multicolumn{1}{l|}{(9)} & 9 & \multicolumn{1}{l|}{(10)} & 7 & \multicolumn{1}{l|}{(9)} & 6 & (8) \\
\multicolumn{1}{|l|}{TRL} & 8 & \multicolumn{1}{l|}{(9)} & 8 & \multicolumn{1}{l|}{(9)} & 7 & \multicolumn{1}{l|}{(8)} & 8 & \multicolumn{1}{l|}{(9)} & 6 & \multicolumn{1}{l|}{(8)} & 5 & (7) \\ \hline
\end{tabular}
\end{adjustbox}
\end{table}
\end{document}
I have tried to use the package adjustbox and tabularx, but I cannot get it to work with me.
Also in my code it has a specific problem with the beginning and end of my adjustbox command.

There is a bit of potential to make your table less wide, e.g. make the column headers multiline, but even then it is hard to fit it in the very narrow text width of the article class. Either decrease the margins to get more room or show the table on a landscape page:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{lscape}
\begin{document}
\begin{landscape}
\centering
\small
\begin{tabular}{|lllllllllllll|}
\hline
& \multicolumn{2}{l}{Li-ion Battery} & \multicolumn{2}{l}{Lead-Acid Battery} & \multicolumn{2}{l}{Redox Flow Battery} & \multicolumn{2}{l}{Sodium-Sulphur} & \multicolumn{2}{l}{Sodium Metal Halide} & \multicolumn{2}{l|}{Zinc-Hybrid Cathode} \\ \cline{2-13}
Parameter & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 & 2018 & 2025 \\ \hline
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Capital Cost - Energy \\ Capacity ()\end{tabular}} & 271 & \multicolumn{1}{l|}{(189)} & 260 & \multicolumn{1}{l|}{(220)} & 555 & \multicolumn{1}{l|}{(393)} & 661 & \multicolumn{1}{l|}{(465)} & 700 & \multicolumn{1}{l|}{(482)} & 265 & (393) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Power Conversion \\ System (PCS) ()\end{tabular}} & 288 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & \multicolumn{1}{l|}{(211)} & 350 & (211) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Balance of Plant (BOP)\\ ()\end{tabular}} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & \multicolumn{1}{l|}{(95)} & 100 & (95) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Construction and \\ Commisioning ()\end{tabular}} & 101 & \multicolumn{1}{l|}{(96)} & 176 & \multicolumn{1}{l|}{(167)} & 190 & \multicolumn{1}{l|}{(180)} & 133 & \multicolumn{1}{l|}{(127)} & 115 & \multicolumn{1}{l|}{(110)} & 173 & (164) \\ \hline
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Total Project Cost \\ ()\end{tabular}} & 1876 & \multicolumn{1}{l|}{(1446)} & 2194 & \multicolumn{1}{l|}{(1854)} & 3430 & \multicolumn{1}{l|}{(2598)} & 3626 & \multicolumn{1}{l|}{(2674)} & 3710 & \multicolumn{1}{l|}{(2674)} & 2202 & (1730) \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Total Project Cost \\ ()\end{tabular}} & 469 & \multicolumn{1}{l|}{(362)} & 549 & \multicolumn{1}{l|}{(464)} & 858 & \multicolumn{1}{l|}{(650)} & 907 & \multicolumn{1}{l|}{(669)} & 928 & \multicolumn{1}{l|}{(669)} & 551 & (433) \\ \hline
\multicolumn{1}{|l|}{O\&M Fixed ()} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & \multicolumn{1}{l|}{(8)} & 10 & (8) \\
\multicolumn{1}{|l|}{O\&M Variable ()} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} & \multicolumn{2}{l|}{0.03} \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}System Round-Trip \\ Efficiency\end{tabular}} & \multicolumn{2}{l|}{0.86} & \multicolumn{2}{l|}{0.72} & \multicolumn{2}{l|}{0.675} & \multicolumn{2}{l|}{0.75} & \multicolumn{2}{l|}{0.83} & \multicolumn{2}{l|}{0.72} \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Response time \\ (limited byPCS)\end{tabular}} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} & \multicolumn{2}{l|}{1 sec} \\
\multicolumn{1}{|l|}{\begin{tabular}[c]{#{}l#{}}Cycles at 80\% Depth\\ of Discharge\end{tabular}} & \multicolumn{2}{l|}{3500} & \multicolumn{2}{l|}{900} & \multicolumn{2}{l|}{10000} & \multicolumn{2}{l|}{4000} & \multicolumn{2}{l|}{3500} & \multicolumn{2}{l|}{3500} \\
\multicolumn{1}{|l|}{Lifetime (Years)} & \multicolumn{2}{l|}{10} & \multicolumn{2}{l|}{2.6} & \multicolumn{2}{l|}{15} & \multicolumn{2}{l|}{13.5} & \multicolumn{2}{l|}{12.5} & \multicolumn{2}{l|}{10} \\
\multicolumn{1}{|l|}{MRL} & 9 & \multicolumn{1}{l|}{(10)} & 9 & \multicolumn{1}{l|}{(10)} & 8 & \multicolumn{1}{l|}{(9)} & 9 & \multicolumn{1}{l|}{(10)} & 7 & \multicolumn{1}{l|}{(9)} & 6 & (8) \\
\multicolumn{1}{|l|}{TRL} & 8 & \multicolumn{1}{l|}{(9)} & 8 & \multicolumn{1}{l|}{(9)} & 7 & \multicolumn{1}{l|}{(8)} & 8 & \multicolumn{1}{l|}{(9)} & 6 & \multicolumn{1}{l|}{(8)} & 5 & (7) \\ \hline
\end{tabular}
\end{landscape}
\end{document}

Related

How to cut , sum each line and reshape data with bash (read input to which file)

I have a file "inp" containing the names of data files I want to process (~200). Part of the file is:
vt-3.00-0.02-80-160k-sphere.out
vt-3.00-0.04-80-160k-sphere.out
vt-3.00-0.06-80-160k-sphere.out
vt-3.00-0.08-80-160k-sphere.out
vt-3.00-0.10-80-160k-sphere.out
Each datafile contains repeating blocks of data, and I want to manipulate a certain part of it:
An example of my repeating data-block:
ST 80 102089
NA 25344 156787 373708 161510 159938 1.235805 9277 482431400
NB 7108 14482 40970 83521 158694
MV 94.577381 337.419276 1.015652 7.253154
VT 1 181 9 7 29 62 580
VT 2 29 12 12 486 13 341
VT 3 486 7 5 59 156 256
VT 4 59 5 5 1199 22 1229
VT 5 1199 10 18 725 379 777
VT 6 725 14 24 587 225 1230
VT 7 587 18 10 183 187 799
VT 8 183 5 5 179 63 629
VT 9 179 5 5 8988 61 9277
VT 10 8988 5 7 1310 2824 1329
VT 11 1310 7 7 2317 417 9088
VT 12 2317 11 5 774 729 1330
VT 13 774 9 9 58 248 2089
VT 14 58 9 5 1949 22 2033
VT 15 1949 7 7 324 607 295
VT 16 324 5 17 3419 106 3097
VT 17 3419 11 13 364 1067 544
VT 18 364 5 5 108 118 1913
VT 19 108 9 7 364 35 427
VT 20 364 23 15 545 116 458
VT 21 545 27 17 727 172 591
VT 22 727 20 16 254 229 629
VT 23 254 5 7 520 84 837
VT 24 520 9 9 3268 165 3323
VT 25 3268 7 5 11 1028 552
VT 26 11 6 14 573 7 3143
VT 27 573 7 13 1492 185 1583
VT 28 1492 6 8 48 467 675
VT 29 48 9 5 48 19 1529
VT 30 48 13 35 2347 19 2164
VT 31 2347 5 13 111 743 318
VT 32 111 6 16 491 39 2451
VT 33 491 11 7 47 154 160
VT 34 47 7 9 1679 18 1724
VT 35 1679 11 7 3650 533 3741
VT 36 3650 6 12 568 1152 1742
VT 37 568 7 11 975 182 3765
VT 38 975 5 5 17 307 602
VT 39 17 6 8 953 9 990
VT 40 953 8 12 439 303 474
VT 41 439 13 9 2183 141 2215
VT 42 2183 5 5 17 684 450
VT 43 17 13 9 184 9 2205
VT 44 184 5 7 65 61 170
VT 45 65 5 7 1136 24 848
VT 46 1136 5 5 2056 360 2071
VT 47 2056 6 8 625 643 1155
VT 48 625 27 17 1658 203 2097
VT 49 1658 8 14 385 529 744
VT 50 385 5 9 618 120 1987
VT 51 618 5 5 439 198 582
VT 52 439 7 5 284 140 631
VT 53 284 7 5 1225 93 1244
VT 54 1225 9 5 1024 391 1129
VT 55 1024 5 15 2504 326 2515
VT 56 2504 5 5 338 794 1040
VT 57 338 6 6 3299 107 3315
VT 58 3299 12 10 682 1042 783
VT 59 682 14 16 441 220 3241
VT 60 441 9 17 132 144 709
VT 61 132 15 7 2941 46 3054
VT 62 2941 13 9 492 926 536
VT 63 492 16 26 2750 159 2964
VT 64 2750 13 5 528 858 761
VT 65 528 12 16 748 166 2588
VT 66 748 5 5 1508 238 1547
VT 67 1508 5 5 153 477 799
VT 68 153 6 10 184 51 1535
VT 69 184 18 8 355 60 458
VT 70 355 8 10 668 113 644
VT 71 668 12 12 919 215 1043
VT 72 919 8 14 489 293 688
VT 73 489 8 10 619 156 1025
VT 74 619 14 10 21 198 523
VT 75 21 18 24 1514 10 1789
VT 76 1514 16 12 3792 477 3803
VT 77 3792 9 5 36 1188 1585
VT 78 36 9 9 74 15 3896
VT 79 74 7 9 517 27 343
VT 80 517 14 6 181 170 202
I'm interested only in those lines which start with VT. I want to omit the first number "1...80" after vt, and sum the following 4 numbers, then place all the 80 "summed" values in one line separated by space. I ended up with the following code after some search:
#!/bin/sh
while read f ; do
fred=${f}.red
#fred=`echo "$f" | sed 's/...$/red/'`
N=1600000
echo "Processing $f file to ${fred} ..."
grep "^VT" $f | tail -$N | cut -d ' ' -f 3,4,5,6 | sed -e 's/\([0-9.]\) /\1+/g' -e 's/.*/(&)/' | bc | tr -d ',' | paste -d' ' $(printf -- '- %.s' {1..80}) > ${fred}
done < inp
So while it can read the file "inp" read those listed filenames one by one, each file in progress is named "$f". For $f" grep all the lines starting with VT, take the last N lines (20k * 80), cut out the 3rd...6th numbers, transform them into (n1+n2+n3+n4), use bc to sum them. Then print 80 times '-' and replace it with the following 80 numbers (this is a funny trick actually)
It seems to work if I use an individual file in the terminal, but in this loop, it doesn't do the last part (reshaping).
Expected output (created via my code performed on an individual file) with tail -166:
1480 5223 3839 135 742 886 280 533 537 1318 1951 1312 831 370 9040 10260 3820 3282 898 2099 2402 3557 3584 450 479 948 1370 1148 844 3917 3414 541 1892 1430 117 2335 2367 634 613 1690 5331 4278 1530 975 929 1331 2654 2245 251 338 1278 3161 2604 2381 2094 914 1164 856 1597 2317 3603 2946 3661 4082 1175 611 3044 3376 3133 3142 1362 2319 1700 328 520 1039 1647 1569 1209 636
1489 5179 3780 135 748 858 226 539 557 1268 1952 1350 798 372 9177 10310 3641 3107 850 2021 2287 3765 3807 482 488 947 1316 1017 786 3806 3291 604 2085 1554 110 2443 2476 624 556 1742 5347 4236 1561 1002 984 1412 2644 2210 223 261 1213 3202 2695 2327 2065 1017 1067 735 1521 2263 3548 2852 3649 4003 1153 599 3095 3455 3284 3296 1304 2266 1671 353 565 1041 1611 1430 1126 664
Resulting output (using the loop over all files):
1480
5223
3839
135
742
886
280
533
537
1318
1951
1312
831
370
9040
10260
3820
3282
898
2099
2402
3557
3584
450
479
948
1370
1148
844
3917
3414
541
1892
1430
117
2335
2367
634
613
1690
5331
4278
1530
975
929
1331
2654
2245
251
338
1278
3161
2604
2381
2094
914
1164
856
1597
2317
3603
2946
3661
4082
1175
611
3044
3376
3133
3142
1362
2319
1700
328
520
1039
1647
1569
1209
636
1489
5179
3780
135
748
858
226
539
557
1268
1952
1350
798
372
9177
10310
3641
3107
850
2021
2287
3765
3807
482
488
947
1316
1017
786
3806
3291
604
2085
1554
110
2443
2476
624
556
1742
5347
4236
1561
1002
984
1412
2644
2210
223
261
1213
3202
2695
2327
2065
1017
1067
735
1521
2263
3548
2852
3649
4003
1153
599
3095
3455
3284
3296
1304
2266
1671
353
565
1041
1611
1430
1126
664
1577
5334
3842
128
607
718
My question:
Is there any more efficient way to do this sum+reshape that I am looking for?
Why does it not work for the loop properly?
tested your code on Ubuntu server it works but I using bash not sh so try to change
#!/bin/sh
with
#!/bin/bash
using sh on my server I get same messy result as your.
In Ubuntu, sh or /bin/sh just points to dash (Debian Almquist shell). sh is supposed to run default command interpreter, which is dash for Ubuntu.
here is a suggestion (not exactly equals as your) in awk:
/^VT/ {
if (lines == "" ) {
lines = $3+$4+$5+$6;
} else {
lines= lines " " $3+$4+$5+$6;
}
if (NR%nlineconcat == 0) {
print lines;
lines = "";
}
}
END {
print lines;
}
Put this code in file program.awk and try:
awk -vnlineconcat=4 -f program.awk *.out
where nlineconcat is the number of line result that will be concatenated in one line.
Or you can run it in one line:
awk -vnlineconcat=4 '/^VT/ { if (lines == "" ) { lines = $3+$4+$5+$6; } else { lines= lines " " $3+$4+$5+$6; } if (NR%nlineconcat == 0) { print lines; lines = ""; } } END { print lines; }' *.out
awk is powerful to manipulate text file.
mawk '(NF=(($_)~__)*((_+=++_+_)+_)) \
? ($--_=$--_= ___)^___^($--_=$_)^!(NF=NF) : _-=_'\
__='^VT [0-9]+ ' FS='[_= \t\n]+' OFS='\t _ '
_ 181 _ 9 _ 7 _ 29
_ 29 _ 12 _ 12 _ 486
_ 486 _ 7 _ 5 _ 59
_ 59 _ 5 _ 5 _ 1199
_ 1199 _ 10 _ 18 _ 725
_ 725 _ 14 _ 24 _ 587
_ 587 _ 18 _ 10 _ 183
_ 183 _ 5 _ 5 _ 179
_ 179 _ 5 _ 5 _ 8988
_ 8988 _ 5 _ 7 _ 1310
_ 1310 _ 7 _ 7 _ 2317
_ 2317 _ 11 _ 5 _ 774
_ 774 _ 9 _ 9 _ 58
_ 58 _ 9 _ 5 _ 1949
_ 1949 _ 7 _ 7 _ 324
_ 324 _ 5 _ 17 _ 3419
_ 3419 _ 11 _ 13 _ 364
_ 364 _ 5 _ 5 _ 108
_ 108 _ 9 _ 7 _ 364
_ 364 _ 23 _ 15 _ 545
_ 545 _ 27 _ 17 _ 727
_ 727 _ 20 _ 16 _ 254
_ 254 _ 5 _ 7 _ 520
_ 520 _ 9 _ 9 _ 3268
_ 3268 _ 7 _ 5 _ 11
_ 11 _ 6 _ 14 _ 573
_ 573 _ 7 _ 13 _ 1492
_ 1492 _ 6 _ 8 _ 48
_ 48 _ 9 _ 5 _ 48
_ 48 _ 13 _ 35 _ 2347
_ 2347 _ 5 _ 13 _ 111
_ 111 _ 6 _ 16 _ 491
_ 491 _ 11 _ 7 _ 47
_ 47 _ 7 _ 9 _ 1679
_ 1679 _ 11 _ 7 _ 3650
_ 3650 _ 6 _ 12 _ 568
_ 568 _ 7 _ 11 _ 975
_ 975 _ 5 _ 5 _ 17
_ 17 _ 6 _ 8 _ 953
_ 953 _ 8 _ 12 _ 439
_ 439 _ 13 _ 9 _ 2183
_ 2183 _ 5 _ 5 _ 17
_ 17 _ 13 _ 9 _ 184
_ 184 _ 5 _ 7 _ 65
_ 65 _ 5 _ 7 _ 1136
_ 1136 _ 5 _ 5 _ 2056
_ 2056 _ 6 _ 8 _ 625
_ 625 _ 27 _ 17 _ 1658
_ 1658 _ 8 _ 14 _ 385
_ 385 _ 5 _ 9 _ 618
_ 618 _ 5 _ 5 _ 439
_ 439 _ 7 _ 5 _ 284
_ 284 _ 7 _ 5 _ 1225
_ 1225 _ 9 _ 5 _ 1024
_ 1024 _ 5 _ 15 _ 2504
_ 2504 _ 5 _ 5 _ 338
_ 338 _ 6 _ 6 _ 3299
_ 3299 _ 12 _ 10 _ 682
_ 682 _ 14 _ 16 _ 441
_ 441 _ 9 _ 17 _ 132
_ 132 _ 15 _ 7 _ 2941
_ 2941 _ 13 _ 9 _ 492
_ 492 _ 16 _ 26 _ 2750
_ 2750 _ 13 _ 5 _ 528
_ 528 _ 12 _ 16 _ 748
_ 748 _ 5 _ 5 _ 1508
_ 1508 _ 5 _ 5 _ 153
_ 153 _ 6 _ 10 _ 184
_ 184 _ 18 _ 8 _ 355
_ 355 _ 8 _ 10 _ 668
_ 668 _ 12 _ 12 _ 919
_ 919 _ 8 _ 14 _ 489
_ 489 _ 8 _ 10 _ 619
_ 619 _ 14 _ 10 _ 21
_ 21 _ 18 _ 24 _ 1514
_ 1514 _ 16 _ 12 _ 3792
_ 3792 _ 9 _ 5 _ 36
_ 36 _ 9 _ 9 _ 74
_ 74 _ 7 _ 9 _ 517
_ 517 _ 14 _ 6 _ 181
The summation part should be trivial.

Laravel 4 DomPDF - PHP not Streaming Issues

I am using laravel 4 with DOMPDF to display an PDF. While i am clicking PDF it will display like below:
%PDF-1.3 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R /F2 9 0 R >> /XObject << /I1 10 0 R >> >> /MediaBox [0.000 0.000 841.890 595.280] >> endobj 4 0 obj [/PDF /Text /ImageC ] endobj 5 0 obj << /Creator (DOMPDF) /CreationDate (D:20160823103816+00'00') /ModDate (D:20160823103816+00'00') >> endobj 6 0 obj << /Type /Page /Parent 3 0 R /Contents 7 0 R >> endobj 7 0 obj << /Filter /FlateDecode /Length 2558 >> stream x��[�n7}�W�1����v$�me%�29+$A�ز��d9F� �~�~j�3�K��l�L`b�����u�{�~;B�����`�)�$�XR��=���Ο��;"X�k��/�N7�E1L�e����¡��~���������w�������<>��/�����}��|���4�,������<�������緟����O�O7'�������?��d���s�WJ�9����1;$�4����:[-PJ/x � �����z�bԇY,��,_8�]-..���*��r��b5��ju�y}y�n���=Z/oV� �����+�U?~��U�#�d���TH��zq}�������f��"!6L��߻�� $��J�\����\�/����ƺ�� 0t���U���7v|~�$��N���������p8�i��<�>4�¥�� ��D¨�-�����C(*�e��mqFbn+���db!��5R4n�w�,�C��-���hSN1������|��� ��b*m��1���[$�����3���)9����N��a�U�y��Փ��[ ���g��|���y �ID�p<��� n�w��[)LU펝� S��z6o�yg���-��{���0�k�I���S��[�������;���5��&��؈��3�E�Y�*o k�� �0�X��6��yg���a�%n;��bw�鼤�#>T#/�X����ް��M�1D��<�E�Y�*o([+z�Zr��>KoPc�yp�ܳ#U��4>�[�F$��`��$��x��j�%5��� �[�X�0�A�y{��;T���auo��Bnf���;T�m�"���ƧkE������3��y�wc�f������+ZJ��'��A+�E�Y�*w {�*=c&'��,�Aav���!��"�,P����+��t�5e���4��y�o�w_>y�c ��$w��#֧҆Ns�n�{h�}D�8�{m)XZVmV�2��c7�'�6ԥQIo�*&t%ͭ�D눒fu�N�衒���.EA4�0 ��HD�g�u=�\�X��ZDs��P4����n��L��g����` �t�����Q�^�����́{�E3�k|�w'u9���h�CxwRw.�L!G��Ļ����R����́w�E3»����L�yg�Z4�!�;�;��� 9j�&�Fl��S�ҝ��\ G����K�r��nz͑̑w�E2y$�8�N�&��,��g�Z$s�;����n�=S2�y��|#�x��x�$s��j�̇������r��M�;�\���Z�Jw&�\ G����K� �L2�s��n�gI��=�"���餐�J7�)�#�,P�d>�нҝy��9J��^2yK��f�{�t=�\��g�&%sT��i՝d. �y��)�U��N�?�V�`�X�������1%i|L ��U��'���2��ih9,a�rF����pCCww�v/7ѩ�N�W P��9#��W���bx:\wU��2Aе0�2,�544wk���D"�/���[2(�C����1ByK����PA��`�C��?��h�[2(/�����*ByK�=��U�eq񂥏t��K�%ByK��K ����y���%��j�'���FP�҇ a�$��>ByK�g����$��%��cxm�&���,}�09�መ\]�w#��dp~�-±I,?�F,oɰ�|�����2#KJ�"��T��8�vr��$��%��͆�3X2�~,1�B����zS�j`c�����^.�}����ޣ�ً���K��p8�9�܌��ߟ����COc�������oX��juw�ipA�Y5%`jqR���=��Xp���&�[�B��`el2��^nG?��YZ!s�����_���tU6��m�֍ n&OhgI���`�k;�)��˦ �Sm�4�쵇������*> endobj 9 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >> endobj 10 0 obj << /Type /XObject /Subtype /Image /Width 64 /Height 64 /Filter /FlateDecode /DecodeParms << /Predictor 15 /Colors 3 /Columns 64 /BitsPerComponent 8>> /ColorSpace /DeviceRGB /BitsPerComponent 8 /Length 929>> stream h�՚�n�#����T�R�#���.�"Z!�����P���\!W[M�.����]�,��*#ș��������3����6��n�O�M]�#����|֯/�����D4�I��LJ�pEQ�$UUM\UU�e�l6�O~C�8��|��DD��>�cD�>5��������k�~�gߴZ ���bQŤ4QY���g��$��"*�b�X�Z�ડ,����#'I�N��O b����nD?Q�睑��Q����j+��z�6Xfp�����{��3w##��k�!��<�<�TU�~�����r��R�y�{���`/1˲p9��k�8��~��slpW?��4ǽ��3VI܂�LY� �ӮY���"��|���#p�>9=,k[�;� u]ߝsl�M��%p����fE��^`\�%=��["�e^b�-�|CHcS[뺶��,��õ��O�n�K�Tv��󒾝��}a�5/��N �M���x�7 "�y\��� ��������L(Dt:��,��wQ�$�T����C���(���cs� �3����9�vƒ�R���}�6��XL�R�t:%Ib��!v�2��������M���#峷����1H�V_(��C�NS�����\sV�ՀS���a����i��~i`��b�c��0D�����N8�I��k}�Ӷ�����}����Y��Ŵ�ug|_�}��������>���M��L��b9/�z�k��Ͼ�ͼ�-����c��i����;B�{�#�֌�O������`�����*�BvΑ����k}���%�9kǪ���yi>������i�N�z���������f�a�O���`�ݎg�/��� endstream endobj xref 0 11 0000000000 65535 f 0000000008 00000 n 0000000073 00000 n 0000000119 00000 n 0000000310 00000 n 0000000347 00000 n 0000000461 00000 n 0000000524 00000 n 0000003155 00000 n 0000003262 00000 n 0000003374 00000 n trailer << /Size 11 /Root 1 0 R /Info 5 0 R >> startxref
How to solve this issues. Please Help Me. Thanks in advance
You can check how to convert data into pdf here. Try this code in to generate pdf. Dont forget to use dompdf library.

How to remove a specific column from a file using awk?

Hello everyone I am working with a text that looks as follows:
& & Training & & & & Early birds & & & & & Test & \\\hline
& EN & ES & IT & DU & EN & ES & IT & DU & EN & ES & IT & DU \\\hline
Users & 152 & 110 & 38 & 34& 42 & 30 & 12 & 10 & 142 & 88 & 36 & 32 \\\hline
18-24 & 58 & 22 & & & 16 & 6 & & & 56 & 18 & & \\
25-34 & 60 & 56 & & &16 & 14 & & & 58 & 44 & &\\
35-49 & 22 & 22 & & & 6& 6 & & & 20 & 18 & &\\
50+ & 12 & 10 & & & 4& 4 & & & 8 &8 & & \\\hline
I am using the & symbol as a column separator, I would like to remove the seven column of my text.txt using awk, I tried:
awk -F "&" '{print $7}' text.txt
and I get:
Early birds
ES
30
6
14
6
4
which is the column that I want to remove from my text.txt, I would like to achieve this using awk, I would like to appreciate any suggestion.
sed works well for this:
$ sed -E 's/(([^&]*&){6})[^&]*&/\1/' text.txt
& & Training & & & & & & & & Test & \\\hline
& EN & ES & IT & DU & EN & IT & DU & EN & ES & IT & DU \\\hline
Users & 152 & 110 & 38 & 34& 42 & 12 & 10 & 142 & 88 & 36 & 32 \\\hline
18-24 & 58 & 22 & & & 16 & & & 56 & 18 & & \\
25-34 & 60 & 56 & & &16 & & & 58 & 44 & &\\
35-49 & 22 & 22 & & & 6& & & 20 & 18 & &\\
50+ & 12 & 10 & & & 4& & & 8 &8 & & \\\hline
(([^&]*&){6}) matches the first six columns and saves them in group \1. [^&]*& matches the seventh. All of that gets replaced with just the first six columns, \1.
With GNU awk for gensub():
$ awk '{print gensub(/(([^&]*&){6})[^&]*&/,"\\1",1)}' file
& & Training & & & & & & & & Test & \\\hline
& EN & ES & IT & DU & EN & IT & DU & EN & ES & IT & DU \\\hline
Users & 152 & 110 & 38 & 34& 42 & 12 & 10 & 142 & 88 & 36 & 32 \\\hline
18-24 & 58 & 22 & & & 16 & & & 56 & 18 & & \\
25-34 & 60 & 56 & & &16 & & & 58 & 44 & &\\
35-49 & 22 & 22 & & & 6& & & 20 & 18 & &\\
50+ & 12 & 10 & & & 4& & & 8 &8 & & \\\hline
With other awks it's a bit more work:
$ awk 'match($0,/([^&]*&){7}/) { tgt=substr($0,1,RLENGTH); sub(/[^&]*&$/,"",tgt); $0=tgt substr($0,RLENGTH+1) } 1' file
& & Training & & & & & & & & Test & \\\hline
& EN & ES & IT & DU & EN & IT & DU & EN & ES & IT & DU \\\hline
Users & 152 & 110 & 38 & 34& 42 & 12 & 10 & 142 & 88 & 36 & 32 \\\hline
18-24 & 58 & 22 & & & 16 & & & 56 & 18 & & \\
25-34 & 60 & 56 & & &16 & & & 58 & 44 & &\\
35-49 & 22 & 22 & & & 6& & & 20 & 18 & &\\
50+ & 12 & 10 & & & 4& & & 8 &8 & & \\\hline
or since you have a string FS rather than a regexp:
$ awk 'BEGIN{FS=OFS="&"} { j=0; for (i=1;i<=NF;i++) if (i!=7) printf "%s%s",(++j>1?OFS:""),$i; print "" }' file
& & Training & & & & & & & & Test & \\\hline
& EN & ES & IT & DU & EN & IT & DU & EN & ES & IT & DU \\\hline
Users & 152 & 110 & 38 & 34& 42 & 12 & 10 & 142 & 88 & 36 & 32 \\\hline
18-24 & 58 & 22 & & & 16 & & & 56 & 18 & & \\
25-34 & 60 & 56 & & &16 & & & 58 & 44 & &\\
35-49 & 22 & 22 & & & 6& & & 20 & 18 & &\\
50+ & 12 & 10 & & & 4& & & 8 &8 & & \\\hline

select a column from a text file using windows batch

I have a text file which has below data
162 y 1 0 518 home47 1
163 y 1 0 520 home41 1
164 y 1 0 522 home43 1
165 y 1 0 524 home45 1
166 y 1 0 526 home46 1
169 y 1 0 531 home50 1
170 y 1 0 533 home52 1
171 y 1 0 535 home54 1
172 y 1 0 537 home56 1
173 y 1 0 539 home58 1
I would like to copy 6th column data from below (home47 to home58) into another text file using windows batch file. How can I perform that
I have tried with below command which is mentioned in another questions, but not working for me
CMD /f:off
FOR /f "tokens=6 delims= " %B in (TabFile.txt) do #echo %B >> 2ColFile.txt
CMD /f:on
#echo off
break>2ColFile.txt
for /f "tokens=6 delims= " %%c in (TabFile.txt) do (
echo %%c
)>>2ColFile.txt
EDIT Have on mind that delimiters are delims=<tab><space> and the could be changed by stackoverflow formater.

Working with octal permissions in bash

How do I get the masked (user) permissions from that permissions octal value?
Output should look like:
testfile1:
Permissions: 644
Masked Permissions: 600
testfile2:
Permissions: 750
Masked Permissions: 700
All I have now is:
for file in $#
do
value=$(stat --printf '%a' $file)
echo "permissions: $value"
maskedvalue= # ???
echo "permissions, masked: $maskedvalue"
done
Given that it is bash, you can do:
printf "%.4o\n" $(( $(stat -f '0%Lp' "$file") & ~$(umask) ))
at least, on Mac OS X, where stat -f '%Lp' means 'print the user, group, other permissions in octal'.
If you're on Linux, you'll need to translate that to the GNU stat syntax, which looks like it probably is:
printf "%.4o\n" $(( $(stat --printf '%a' "$file") & ~$(umask) ))
The spaces after $(( and before )) are not strictly needed in the sense that the shell knows what to do even if they are missing; likewise the spaces around the &. OTOH, if anyone else has to read the code, you probably want those spaces there.
Test code:
file="./mode-file"
trap "rm -f $file; exit 1" 0 1 2 3 13 15
cp /dev/null "$file"
for mode in 777 755 644 640 444 440 400
do
chmod $mode $file
ls -l $file
for umask in 002 022 027 033 037 077 177
do
umask $umask
printf "$mode & ~$umask = %.4o\n" $(( $(stat -f '0%Lp' "$file") & ~$(umask) ))
done
done
rm -f $file
trap 0
Example output:
-rwxrwxrwx 1 jleffler staff 0 Nov 11 20:57 ./mode-file
777 & ~002 = 0775
777 & ~022 = 0755
777 & ~027 = 0750
777 & ~033 = 0744
777 & ~037 = 0740
777 & ~077 = 0700
777 & ~177 = 0600
-rwxr-xr-x 1 jleffler staff 0 Nov 11 20:57 ./mode-file
755 & ~002 = 0755
755 & ~022 = 0755
755 & ~027 = 0750
755 & ~033 = 0744
755 & ~037 = 0740
755 & ~077 = 0700
755 & ~177 = 0600
-rw-r--r-- 1 jleffler staff 0 Nov 11 20:57 ./mode-file
644 & ~002 = 0644
644 & ~022 = 0644
644 & ~027 = 0640
644 & ~033 = 0644
644 & ~037 = 0640
644 & ~077 = 0600
644 & ~177 = 0600
-rw-r----- 1 jleffler staff 0 Nov 11 20:57 ./mode-file
640 & ~002 = 0640
640 & ~022 = 0640
640 & ~027 = 0640
640 & ~033 = 0640
640 & ~037 = 0640
640 & ~077 = 0600
640 & ~177 = 0600
-r--r--r-- 1 jleffler staff 0 Nov 11 20:57 ./mode-file
444 & ~002 = 0444
444 & ~022 = 0444
444 & ~027 = 0440
444 & ~033 = 0444
444 & ~037 = 0440
444 & ~077 = 0400
444 & ~177 = 0400
-r--r----- 1 jleffler staff 0 Nov 11 20:57 ./mode-file
440 & ~002 = 0440
440 & ~022 = 0440
440 & ~027 = 0440
440 & ~033 = 0440
440 & ~037 = 0440
440 & ~077 = 0400
440 & ~177 = 0400
-r-------- 1 jleffler staff 0 Nov 11 20:57 ./mode-file
400 & ~002 = 0400
400 & ~022 = 0400
400 & ~027 = 0400
400 & ~033 = 0400
400 & ~037 = 0400
400 & ~077 = 0400
400 & ~177 = 0400
NB: Tested on Mac OS X 10.9 (Mavericks). If you are using a GNU/Linux platform, you must change the stat command to use the notation that works on your machine.

Resources