Csv table queries

factor out repeated line