Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. BEGIN {
  2. FS = "\t"
  3. ORS = ""
  4. }
  5.  
  6. NR == 1 {
  7. cols = ""
  8. for (k=1; k <= NF; ++k){
  9. cols = cols "c"
  10. }
  11. print "\\begin{tabular}{" cols "}\n"
  12. print "\\toprule\n"
  13. }
  14.  
  15. NR ==2 {
  16. print "\\midrule\n"
  17. }
  18.  
  19. {
  20. for (i=1; i <= NF; ++i){
  21. if (NR ==1){
  22. print "\\bfseries "
  23. }
  24.  
  25. x = sprintf("%.2g", $i)
  26. if ($i != "" && (x != "0" || $i == 0)) {
  27. printf "%.2f", $i
  28. } else {
  29. print $i
  30. }
  31.  
  32. if (i < NF) {
  33. print " & "
  34. } else {
  35. print "\\\\\n"
  36. }
  37. }
  38. }
  39.  
  40. END {
  41. print "\\bottomrule\n\\end{tabular}\n"
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement