add counter that counts column values and writes table with column values as headers and count as column values