Skip to main content

reader library for csv files.

Project description

Introduction

Welcome to my small python project. This library just provides some functions to read from csv files. I developed this library for fun. If anyone wants to contribute, feel free to contact me or open an issue. This library uses the built-in csv module

Installation

Type this into your command prompt: pip install csv-reader

Usage

at the top of your py files:

from reader import Reader

in your code:

with Reader.openWithName("test.csv") as file:
    for line in file:
        print(line)

Documentation

openWithName(name: str)

opens a file with the given file name and returns a context manager.
name - the name of the csv file.
throws: FileNotFoundError - when the file could not be found. e.g.

with Reader.openWithName("test.csv") as file:
    for line in file:
        print(line)

note: when used in a `for` loop, each `line` is a list of values in each line of the file.
openWithFile(file: TextIO)

returns a context manager from an already opened file.
file - the file object.
throws: FileNotFoundError - when the file could not be found. e.g.

with Reader.openWithFile(open("test.csv" newline="")) as file:
    for line in file:
        print(line)

note: when used in a `for` loop, each `line` is a list of values in each line of the file.
readFromName(name: str)

opens a file with given name and returns a context manager that yields an iterator that yields each line in the file.
name - the name of the csv file.
throws: FileNotFoundError - when the file could not be found. e.g.

with Reader.readFromName("test.csv") as file:
    for line in file:
        print(line)

note: `line` is a string.
readFromFile(file: TextIO)

returns an context manager from an already opened file that yields an iterator that yields each line in the file.
file - the file object.
throws: FileNotFoundError - when the file could not be found. e.g.

with Reader.readFromFile(open("test.csv", newline="")) as file:
    for line in file:
        print(line)

note: `line` is a string.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

csv_reader-1.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file csv_reader-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: csv_reader-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for csv_reader-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebbda94537614b3a617cd7cae3115596814beea13828f67b6f5130d5c9aee54f
MD5 b1ba66f0e0abb139848f98f2334831e2
BLAKE2b-256 80813f8f59c334bd6cd87f15508c35e72f3139dd468bab523d6347a17c26fa73

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page