Skip to main content

Stream and convert BCP format files

Project description

BCP Reader

A reader for BCP-format data files. BCP files are similar to CSV files but contain a multi-character line and field delimiters. The default delimiters used are:

  • field delimiter: @**@
  • line delimiter: *@@*

Python's csv module can only deal with single character delimiters, so this module has a reader function and DictReader class which should be drop-in replacements for python's csv module equivalents.

Credits

The author of the main method is Gertjan van den Burg of the Alan Turing Institute. It was based on a method originally developed by David Kane at NCVO.

Installation

Install with pip install bcp-reader

Usage

The module can be used by importing from the bcp module in a python script:

import bcp

with open('path_to_bcp_file.bcp') as f:
    bcpreader = bcp.reader(f)
    for row in bcpreader:
        print(row)
        # ["Value 1", "Value 2"]

with open('path_to_bcp_file.bcp') as f:
    bcpreader = bcp.DictReader(f, fieldnames=["field 1", "field 2"])
    for row in bcpreader:
        print(row)
        # {"field 1": "Value 1", "field 2": "Value 2"}

You can also use it via the command line to convert a BCP file to CSV:

bcp path_to_bcp_file.bcp > csv_output.csv

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bcp-reader, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size bcp_reader-0.1.1-py3-none-any.whl (4.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size bcp-reader-0.1.1.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page