當前位置: 首頁>>代碼示例>>Python>>正文


Python csvcut.CSVCut類代碼示例

本文整理匯總了Python中csvkit.utilities.csvcut.CSVCut的典型用法代碼示例。如果您正苦於以下問題:Python CSVCut類的具體用法?Python CSVCut怎麽用?Python CSVCut使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CSVCut類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_with_bzip2

    def test_with_bzip2(self):
        args = ['-c', '1,3', 'examples/dummy.csv.bz2']
        output_file = six.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = six.StringIO(output_file.getvalue())
        reader = agate.reader(input_file)

        self.assertEqual(next(reader), ['a', 'c'])
        self.assertEqual(next(reader), ['1', '3'])
開發者ID:pcdingman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例2: test_exclude

    def test_exclude(self):
        args = ['-C', '1,3', 'examples/dummy.csv']
        output_file = six.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = six.StringIO(output_file.getvalue())
        reader = agate.reader(input_file)

        self.assertEqual(next(reader), ['b'])
        self.assertEqual(next(reader), ['2'])
開發者ID:pcdingman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例3: test_include_and_exclude

    def test_include_and_exclude(self):
        args = ['-c', '1,3', '-C', '3', 'examples/dummy.csv']
        output_file = six.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = six.StringIO(output_file.getvalue())
        reader = CSVKitReader(input_file)

        self.assertEqual(next(reader), ['a'])
        self.assertEqual(next(reader), ['1'])
開發者ID:DATAQC,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例4: test_names

    def test_names(self):
        args = ['-n', 'examples/dummy.csv']
        output_file = six.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = six.StringIO(output_file.getvalue())

        self.assertEqual(next(input_file), '  1: a\n')
        self.assertEqual(next(input_file), '  2: b\n')
        self.assertEqual(next(input_file), '  3: c\n')
開發者ID:pcdingman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例5: test_no_header_row

    def test_no_header_row(self):
        args = ['-c', '2', '--no-header-row', 'examples/no_header_row.csv']
        output_file = six.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = six.StringIO(output_file.getvalue())
        reader = agate.reader(input_file)

        self.assertEqual(next(reader), ['column2'])
        self.assertEqual(next(reader), ['2'])
開發者ID:pcdingman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例6: test_include_and_exclude

    def test_include_and_exclude(self):
        args = ["-c", "1,3", "-C", "3", "examples/dummy.csv"]
        output_file = StringIO.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = StringIO.StringIO(output_file.getvalue())
        reader = CSVKitReader(input_file)

        self.assertEqual(reader.next(), ["a"])
        self.assertEqual(reader.next(), ["1"])
開發者ID:nhoffman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例7: test_with_bzip2

    def test_with_bzip2(self):
        args = ["-c", "1,3", "examples/dummy.csv.bz2"]
        output_file = StringIO.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = StringIO.StringIO(output_file.getvalue())
        reader = CSVKitReader(input_file)

        self.assertEqual(reader.next(), ["a", "c"])
        self.assertEqual(reader.next(), ["1", "3"])
開發者ID:nhoffman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例8: test_names

    def test_names(self):
        args = ["-n", "examples/dummy.csv"]
        output_file = StringIO.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = StringIO.StringIO(output_file.getvalue())

        self.assertEqual(input_file.next(), "  1: a\n")
        self.assertEqual(input_file.next(), "  2: b\n")
        self.assertEqual(input_file.next(), "  3: c\n")
開發者ID:nhoffman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例9: test_no_header_row

    def test_no_header_row(self):
        args = ["-c", "2", "--no-header-row", "examples/no_header_row.csv"]
        output_file = StringIO.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = StringIO.StringIO(output_file.getvalue())
        reader = CSVKitReader(input_file)

        self.assertEqual(reader.next(), ["column2"])
        self.assertEqual(reader.next(), ["2"])
開發者ID:nhoffman,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例10: test_simple

    def test_simple(self):
        args = ['-c', '1,3', 'examples/dummy.csv']
        output_file = StringIO.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = StringIO.StringIO(output_file.getvalue())
        reader = CSVKitReader(input_file)

        self.assertEqual(reader.next(), ['a', 'c'])
        self.assertEqual(reader.next(), ['1', '3'])
開發者ID:pallih,項目名稱:csvkit,代碼行數:12,代碼來源:test_csvcut.py

示例11: test_unicode

    def test_unicode(self):
        args = ['-c', '1,3', 'examples/test_utf8.csv']
        output_file = six.StringIO()
        utility = CSVCut(args, output_file)

        utility.main()

        input_file = six.StringIO(output_file.getvalue())
        reader = agate.reader(input_file)

        self.assertEqual(next(reader), ['a', 'c'])
        self.assertEqual(next(reader), ['1', '3'])
        self.assertEqual(next(reader), ['4', u'ʤ'])
開發者ID:pcdingman,項目名稱:csvkit,代碼行數:13,代碼來源:test_csvcut.py


注:本文中的csvkit.utilities.csvcut.CSVCut類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。