Maguro
Maguro is a Python-wrapper for DSV files.
Other behaviors are similar to a native Python list, the tutorial below only covers add-on features specific to Maguro.
Official Release
Maguro can now be used on your Python projects through PyPi by running pip command on a Python-ready environment.
pip install maguro --upgrade
Current version is 1.1.0, but more updates are coming soon. This is compatible with Python version 3.9 or with the latest.
package import
from maguro import Maguro
basic usage
dataset = Maguro("dataset.csv")
custom encoding
dataset = Maguro("dataset.csv", encoding="utf-8")
custom delimiter
dataset = Maguro("dataset.tsv", delimiter="\t")
clear
Remove all items inside the list by using dataset.clear() method.
add items
Use dataset.append(value) to add new item in the list.
add only if unique
Use dataset.append(value, unique=True) to add if item is not yet in the list.
sorting
Use dataset.sort() to sort the list alphabetically.
reverse
Use dataset.reverse() to reverse the list.
remove item
Use dataset.pop(index) to to remove the first occurence in the list.
to formatted string
Return a formatted string, concatenated by the specificied delimiter, by using dataset.pack() method.
raw list
Return a raw list (of list data type) by using dataset.unpack() method.
loop over items
for item in dataset:
print(item)
remove item
Remove existing (or non-existing) value.
Usage: dataset.remove(value)
insert item
Insert data at a specific index
Usage: dataset.insert(index, value)
load list
Loading new data into a Maguro object will replace previous contents.
Usage: dataset.load(iterable)
extend list
Extending original lists follows the same list syntax.
Usage: dataset.extend(iterable)
remove duplicates
Maguro leverages Python list(set()) casting to remove duplicates.
Usage: dataset.distinct()
Creating 2D arrays
test = Maguro("temp/03b-2d.csv", delimiter=",", newline="\n")
test.append(["Juan", 23, "Male", 72, 168, False])
test.append(["Pedro", 22, "Male", 68, 172, True])
test.append(["Maria", 19, "Female", 56, 162, True])
Force Quotations on Strings
test = Maguro("temp/9-tab-separated-values.tsv", delimiter="\t", newline="\n", quote_strings=True)
test.clear()
test.append(["a", "b", "c", "d", "e"])
test.append(["1", "2", "3", "4", "5"])
test.append([1, 2, 3, 4, 5])
print(test.unpack())
Convert Yes, y, No, and n to equivalent Boolean data type (run-time only)
test = Maguro("temp/04-booleans.csv", delimiter=",", newline="\n", allow_boolean=True)
Header methods
# Get the header
test = Maguro("temp/12a-header.csv", delimiter=",", newline="\n", quote_strings=True, has_header=True)
print(test.get_header())
# Replace with new header
# equivalent to: test[0] = [*]
test = Maguro("temp/12b-header.csv", delimiter=",", newline="\n", quote_strings=True, has_header=True)
test.set_header(["earthquakeId", "occurred_on", "latitude", "longitude", "depth", "magnitude", "calculation_method", "network_id", "place", "cause"])
print(test[0])
# Add new header
test = Maguro("temp/12c-header.csv", delimiter=",", newline="\n", quote_strings=True)
test.set_header(["earthquake_id", "occurred_on", "latitude", "longitude", "depth", "magnitude", "calculation_method", "network_id", "place", "cause"])
print(test[0])
print(test[1])
# Remove header if set
# exquivalent to: test = test[1:]
test = Maguro("temp/13-header.csv", delimiter=",", newline="\n", quote_strings=True, has_header=True)
test.behead()
print(test[0])
Expand all valid child list to max-length
test = Maguro("temp/14-expand.csv", delimiter=",", newline="\n")
test.clear()
test.append(["name", "age", "gender", "address"])
test.append(["Juan", "22", "M"])
test.append(["Pedro", "21", "M", "Mars"])
test.append(["Maria", "18", "F", "Earth", "Blue"])
test.append("Soledad")
test.expand()
print(test.pack())
Metadata
Release files for maguro 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| maguro-1.1.3.tar.gz | 11.8 kB | Without provenance | Details for maguro-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maguro-1.1.3-py3-none-any.whl | Python 3 | none | any | Details for maguro-1.1.3-py3-none-any.whl |
Total release size: 18.2 kB
Release files / maguro-1.1.3.tar.gz
| Download URL | maguro-1.1.3.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20719ad8ce1bc4f99b77394ec8eabea8bd9a60b90a64f607f227f43e4c94180e
|
|
BLAKE2b-256 checksum How to use checksums |
914fd95ab6ccda86e4180a763ae178e89515f34da639f71e2e0daae1bfada422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / maguro-1.1.3-py3-none-any.whl
| Download URL | maguro-1.1.3-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
792aa6ad34a9774b7378068596aa64b0a6cac72d0a5d92c7eedcd7bf9a408b5f
|
|
BLAKE2b-256 checksum How to use checksums |
a55262b67aab76300af48d96205c2757ad4284259ef83678ac78185ccbebe94e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Security for maguro 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.