Exemplo n.º 1
0
 def b_fcsv_writerow(bm):
     for i in bm:
         writer = fcsv.writer(
             'b_fcsv.csv')  # , quoting=csv.QUOTE_NONNUMERIC)
         writer.writerow(source[0])
         writer.writerow(source[1])
         writer.writerow(source[2])
Exemplo n.º 2
0
def write_list():
    writer = fcsv.writer('v.csv')
    writer.writerow(("Hello", "こんにちは", "csv"))
    writer.writerows((
        ("Hello1", "こんにちは1", "csv1"),
        ("World2", "せかい2", "csv2"),
    ))
Exemplo n.º 3
0
def write_tuple():
    writer = fcsv.writer('v.csv')
    writer.writerow(["Hello", "こんにちは", "csv"])
    writer.writerows([
        ["Hello1", "こんにちは1", "csv1"],
        ("World2", "せかい2", "csv2"),
    ])
Exemplo n.º 4
0
    def test_writer_opt_delimiter_verticalbar(self):
        rowdata = [1, 2, -4.1, "Hello", True, False, None]
        # fcsv
        w = fcsv.writer(self.fo.name, delimiter="|")
        w.writerow(rowdata)
        with open(self.fo.name) as f:
            ret = f.read().strip()
            self.assertEqual("1|2|-4.1|Hello|True|False|", ret)

        # std
        with open(self.fo.name, 'w') as f:
            w = csv.writer(f, delimiter="|")
            w.writerow(rowdata)

        # validation
        with open(self.fo.name) as f:
            std_ret = f.read().strip()
            self.assertEqual(ret, std_ret)
Exemplo n.º 5
0
    def test_writer_opt_dialect_and_delimiter(self):
        rowdata = [1, 2, -4.1, "Hello", True, False, None]
        # fcsv
        w = fcsv.writer(self.fo.name, dialect="excel", delimiter=";")
        w.writerow(rowdata)
        with open(self.fo.name) as f:
            ret = f.read().strip()
        self.assertEqual("1;2;-4.1;Hello;True;False;", ret)

        # std
        with open(self.fo.name, 'w') as f:
            w = csv.writer(f, dialect="excel", delimiter=";")
            w.writerow(rowdata)
        with open(self.fo.name) as f:
            std_ret = f.read().strip()

        # validation
        self.assertEqual(ret, std_ret)
Exemplo n.º 6
0
    def test_writer_with_list(self):
        rowdata = [1, 2, -4.1, "Hello", True, False, None]
        # fcsv
        w = fcsv.writer(self.fo.name)
        w.writerow(rowdata)
        with open(self.fo.name) as f:
            ret = f.read().strip()
            self.assertEqual("1,2,-4.1,Hello,True,False,", ret)

        # std
        with open(self.fo.name, 'w') as f:
            w = csv.writer(f)
            w.writerow(rowdata)

        # validation
        with open(self.fo.name) as f:
            std_ret = f.read().strip()
            self.assertEqual(ret, std_ret)