Skip to main content

A simple package to parse CSV

Project description

Simple CSV parser

This is a simple package designed to serialize and deserialize CSV.

Installing

Use Python PIP

pip install SimpleCSVParser

Usage

The package contains a single class which is CSVFile that represents a CSV file.

# you can use CSVInitError for catching exceptions, 
# it's the only exception thrown by the library.
from SimpleCSVParser import CSVHandle, CSVInitError


# create a new instance from a file.
parsed_csv: CSVHandle = CSVHandle.from_file("my_csv_file.csv")
# you can also create a new instance from a raw string.
parsed_csv = CSVHandle("your;csv;here\n1;2;3")

# You can also specify the separator in a second arugment.
parsed_csv: CSVHandle = CSVHandle.from_file("my_csv_file.csv", ';')
parsed_csv = CSVHandle("your;csv;here\n1;2;3", ';')

# or initializing from an array
parsed_csv: CSVHandle = CSVHandle.from_array(["first", "second"], [1, 2])

# Obtain a specific element, the second argument being 
# the row number not taking the column name into account.
parsed_csv[("Column Name", 0)]

# Obtain a list[list[any]] of the serialized CSV, the first
# column being the column names so, row[column[any]].
parsed_csv.get_raw()

# Obtain a string from the CSV instance.
parsed_csv.to_string()

# You can optionally specify if it's going to add the 
# separator specifier if so, it's going to append 
# "sep={separator}" to the start.
parsed_csv.to_string(True) # default being true.

# There is also a shortcut for writing the CSV to a file.
parsed_csv.write_to_file("./path_to_file.csv")

# And of course define if it's going to specify the separator.
parsed_csv.write_to_file("./path_to_file.csv", True) # default being true.

Contributing

You can make a pull request, and it will be checked as soon as possible.

Project details


Download files

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

Source Distribution

simplecsvparser-1.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplecsvparser-1.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file simplecsvparser-1.0.1.tar.gz.

File metadata

  • Download URL: simplecsvparser-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for simplecsvparser-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a7c503ff317f207fe88cdc0ce7509c8d5d778a019fa52fd9d374c997aced867d
MD5 e8740e3ff288ef1cafb5bfe4a7d35de7
BLAKE2b-256 294996e9802c526bfc04aa610e00146fb3d1a85c251b68363fd5e00ee282c456

See more details on using hashes here.

File details

Details for the file simplecsvparser-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simplecsvparser-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9150cd0d70edbe788d5005ffa74d727350aba84a1bd6ceb0a2f3e8292a506518
MD5 563f8e435e5197e02258f0ed1d3f523e
BLAKE2b-256 0535bab84bd48769b7bb2bd585b3abe857864756db8967b4e0cdb20fc6d05c55

See more details on using hashes here.

Supported by

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