Skip to content

Basic Docs

Josh edited this page Dec 12, 2018 · 2 revisions

Installation

psv can be installed via pip install psv.

Basic Usage

psv operates as a wrapper around python's csv library, mean't to remove repetitive code and allow rapid script creations of csv processing or manipulation.

Loading files

Basic guide to loading files

import psv

# psv will automatically open files with some default arguments applied to python's built-in open().
# Use help(psv.load) to see all the arguments that are passable. 
# All of them can be changed to a files particular need, though outside of encoding this is rarely needed. 
document = psv.load("File.csv") 

# Separate Encoding `
# ISO-8859-1 is one of the common non utf-8 encodings spit out by excel like programs.
document = psv.load("File.csv", encoding="ISO-8859-1") 

# Additionally, files can be directly supplied
# Note: For safety reasons psv currently closes the file, whether or not the file provided is in a context manager or later closed manually.
# This may change in the future though, so don't rely on it.
with open("file.csv", "r") as f:
    `document = psv.load(f)

# Note: This will close the file, however this is not guaranteed for future releases. 
document = psv.load(open("file.csv", "r"))
Clone this wiki locally