Skip to main content

This library has a function to split the data list into several small sections

Project description

List Slicer

This library has a function to split the data list into several small sections

Usage

Use the following code to split your list data

Split List data

from listslicer.slicer import Slicer

#My list data
data = [
    200, 1230, 15, 2200, 5550
]
#2 is amount to split
data_slice = Slicer.cut(data, 2)
print(data_slice)

Result

[[200, 1230], [15, 2200], [5550]]

Example to split Dictionary

data = [
    {
        "foodname": "Ayam Bakar",
        "price": 12000
    }, 
    {
        "foodname": "Jus Mangga",
        "price": 7000
    },
    {
        "foodname": "Mie Goreng",
        "price": 9000
    },
    {
        "foodname": "Chicken Katsu",
        "price": 15000
    },
]
print(slicer.cut(data, 2))

Result

[
    [{'price': 12000, 'foodname': 'Ayam Bakar'}, {'price': 7000, 'foodname': 'Jus Mangga'}], 
    [{'price': 9000, 'foodname': 'Mie Goreng'}, {'price': 15000, 'foodname': 'Chicken Katsu'}]
]

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

list-slice-1.0.0.tar.gz (2.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page