Example #1
0
def _build_lots_of_customers_csv(target_csv_path, customer_count=1000):
    assert target_csv_path is not None

    _log.info('write lots of customers to "%s"', target_csv_path)
    randomizer = random.Random(2)
    with io.open(target_csv_path, "w", newline='', encoding='cp1252') as target_csv_file:
        csv_writer = _compat.csv_writer(target_csv_file)
        for customer_id in range(1, customer_count + 1):
            csv_writer.writerow(dev_test.create_test_customer_row(customer_id, randomizer))
Example #2
0
    def __init__(self, target, data_format):
        assert target is not None
        assert data_format is not None
        assert data_format.format == data.FORMAT_DELIMITED
        assert data_format.is_valid

        super(DelimitedRowWriter, self).__init__(target, data_format)
        keywords = _as_delimited_keywords(data_format)
        self._delimited_writer = _compat.csv_writer(self._target_stream, **keywords)
Example #3
0
    def __init__(self, target, data_format):
        assert target is not None
        assert data_format is not None
        assert data_format.format == data.FORMAT_DELIMITED
        assert data_format.is_valid

        super(DelimitedRowWriter, self).__init__(target, data_format)
        keywords = _as_delimited_keywords(data_format)
        self._delimited_writer = _compat.csv_writer(self._target_stream,
                                                    **keywords)
Example #4
0
def _build_lots_of_customers_csv(target_csv_path, customer_count=1000):
    # TODO: Use a random seed to generate the same data every time.
    assert target_csv_path is not None

    _log.info('write lots of customers to "%s"', target_csv_path)
    with io.open(target_csv_path, "w", newline='',
                 encoding='cp1252') as target_csv_file:
        csv_writer = _compat.csv_writer(target_csv_file)
        for customerId in range(customer_count):
            csv_writer.writerow(dev_test.create_test_customer_row(customerId))
def _build_lots_of_customers_csv(target_csv_path, customer_count=1000):
    assert target_csv_path is not None

    _log.info('write lots of customers to "%s"', target_csv_path)
    randomizer = random.Random(2)
    with io.open(target_csv_path, "w", newline='',
                 encoding='cp1252') as target_csv_file:
        csv_writer = _compat.csv_writer(target_csv_file)
        for customer_id in range(1, customer_count + 1):
            csv_writer.writerow(
                dev_test.create_test_customer_row(customer_id, randomizer))
Example #6
0
def to_csv(ods_source_path, csv_target_path, dialect='excel', sheet=1):
    """
    Convert ODS file in `odsFilePath` to CSV using `dialect` and store the result in `csvTargetPath`.
    """
    assert ods_source_path is not None
    assert csv_target_path is not None
    assert dialect is not None
    assert sheet is not None
    assert sheet >= 1

    with io.open(csv_target_path, 'w', newline='', encoding='utf-8') as csv_target_file:
        csv_writer = _compat.csv_writer(csv_target_file, dialect)
        csv_writer.writerows(rowio.ods_rows(ods_source_path, sheet))
Example #7
0
def toCsv(odsFilePath, csvTargetPath, dialect="excel", sheet=1):
    """
    Convert ODS file in `odsFilePath` to CSV using `dialect` and store the result in `csvTargetPath`.
    """
    assert odsFilePath is not None
    assert csvTargetPath is not None
    assert dialect is not None
    assert sheet is not None
    assert sheet >= 1

    with io.open(csvTargetPath, 'w', newline='',
                 encoding='utf-8') as csvTargetFile:
        csv_writer = _compat.csv_writer(csvTargetFile, dialect)
        csv_writer.writerows(rowio.ods_rows(odsFilePath, sheet))