当前位置: 首页>>代码示例>>Python>>正文


Python CSVCut.main方法代码示例

本文整理汇总了Python中csvkit.utilities.csvcut.CSVCut.main方法的典型用法代码示例。如果您正苦于以下问题:Python CSVCut.main方法的具体用法?Python CSVCut.main怎么用?Python CSVCut.main使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在csvkit.utilities.csvcut.CSVCut的用法示例。


在下文中一共展示了CSVCut.main方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_with_bzip2

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例2: test_exclude

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例3: test_include_and_exclude

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例4: test_names

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例5: test_no_header_row

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例6: test_include_and_exclude

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例7: test_with_bzip2

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例8: test_names

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例9: test_no_header_row

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例10: test_simple

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:14,代码来源:test_csvcut.py

示例11: test_unicode

# 需要导入模块: from csvkit.utilities.csvcut import CSVCut [as 别名]
# 或者: from csvkit.utilities.csvcut.CSVCut import main [as 别名]
    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,代码行数:15,代码来源:test_csvcut.py


注:本文中的csvkit.utilities.csvcut.CSVCut.main方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。