Skip to content

Python tools for reading and writing sequential record-oriented data.

License

Notifications You must be signed in to change notification settings

mdklatt/serial-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serial-core

Python 3.8 Python 3.9 Python 3.10 Python 3.11 GitHub release (latest SemVer) MIT License CI Tests

The serial-python Python library provides extensible tools for reading and writing record-oriented data in various formats. The core library provided here is contained in the serial.core package. Library extensions will be contained in their own packages under the serial namespace.

Features

  • Read/write delimited and fixed-width data
  • Named, typed, and formatted data fields
  • Filtering
  • Aggregation
  • Sorting

Basic Example

""" Read a comma-delimited file.

"""
from serial.core import DelimitedReader
from serial.core import IntField
from serial.core import StringField

def name_filter(record):
    """ Convert name to upper case. """
    record["name"] = record["name"].upper()
    return record

fields = (
    StringField("name", 0),
    IntField("age", 1)
)
with DelimitedReader.open("ages.csv", fields, ",") as reader:
    reader.filter(name_filter)
    for record in reader:
        print("{name} is {age} years old".format(**record))

Installation

Install the library from GitHub:

$ python -m pip install git+git://github.com/mdklatt/serial-python.git

About

Python tools for reading and writing sequential record-oriented data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published