Exemplo n.º 1
0
 def _read_test(self, table, dialect):
     tmpfname = self._write_tmpfile(table, dialect)
     exp = [list(map(str, r)) for r in table]
     try:
         self.assertEqual(exp, wrappers.read_csv(tmpfname))
     finally:
         os.unlink(tmpfname)
Exemplo n.º 2
0
    def _read_test_rows(self, rows, expected):
        contents = "\n".join(rows)
        tmpfd, tmpfname = tempfile.mkstemp()
        tmpid = os.fdopen(tmpfd, "w")
        tmpid.write(contents)
        tmpid.close()

        try:
            self.assertEqual(expected, wrappers.read_csv(tmpfname))
        finally:
            os.unlink(tmpfname)
Exemplo n.º 3
0
    def _read_test(self, table, dialect):
        tmpfd, tmpfname = tempfile.mkstemp()
        tmpid = os.fdopen(tmpfd, "w")
        w = writer(tmpid, dialect=dialect)
        w.writerows(table)
        tmpid.close()

        exp = [list(map(str, r)) for r in table]
        try:
            self.assertEqual(exp, wrappers.read_csv(tmpfname))
        finally:
            os.unlink(tmpfname)
Exemplo n.º 4
0
 def handle(self):
     verbose = self.io.verbosity > 0
     num_chars = parse_int(self.option("num-chars"), "num-chars")
     try:
         rows = read_csv(
             self.argument("path"),
             encoding=self.option("encoding"),
             num_chars=num_chars,
             verbose=verbose,
         )
     except NoDetectionResult:
         self.line("Dialect detection failed.")
     if self.option("transpose"):
         rows = list(map(list, zip(*rows)))
     tabview.view(rows)