Registry / serialization / rcslice

rcslice

JSON →
library1.1.0pypypi✓ verified 87d ago

rcslice is a Python library (version 1.1.0) designed to slice lists of 'sliceables' using a 1-indexed system where both start and end indices are inclusive. This utility helps in specific use cases, such as slicing file content line by line or column by column, offering an alternative to Python's native 0-indexed, end-exclusive slicing. It appears to be a stable, focused utility with infrequent releases.

pip install rcslice
INSTALL
IMPORT
SIG · RCSLICE
R
rcslice
serializationpythonv1.1.0
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RowSlice
from rcslice import RowSlice

This quickstart demonstrates how to instantiate `RowSlice` and perform basic row and column slicing. It also illustrates how to use a custom separator when combining multiple slice operations, which is crucial for controlling output formatting.

from rcslice import RowSlice # Create a list of sliceable items data = [ "Header 1,Header 2,Header 3", "Row 1 Col 1,Row 1 Col 2,Row 1 Col 3", "Row 2 Col 1,Row 2 Col 2,Row 2 Col 3", "Row 3 Col 1,Row 3 Col 2,Row 3 Col 3", "Row 4 Col 1,Row 4 Col 2,Row 4 Col 3" ] # Initialize RowSlice (no separator for single slice operations) rs = RowSlice() # Example 1: Slice rows 1 to 3 (inclusive) # Input '1-3' means first element to third element print("\n--- Slicing rows 1-3 ---") sliced_rows = rs.slice(data, '1-3') for item in sliced_rows: print(item) # Example 2: Slice row 2, column 2 (1-indexed) print("\n--- Slicing Row 2, Column 2 ---") sliced_single_cell = rs.slice(data, '2.2') for item in sliced_single_cell: print(item) # Example 3: Multiple slices with a custom separator # Slices: row 1-2, then row 4 # The separator ['---'] means a single '---' line will be inserted between the slices. rs_with_separator = RowSlice(['---']) print("\n--- Multiple Slices with Separator (rows 1-2, then row 4) ---") multi_sliced_data = rs_with_separator.slice(data, '1-2,4') for item in multi_sliced_data: print(item)
Debug
Known issues
gotcharcslice uses 1-indexed slicing where both the start and end indices are *inclusive*, directly contrasting Python's native 0-indexed, end-exclusive slicing. This is the most common source of 'off-by-one' errors and unexpected results.
fix
Always remember to use 1-based indexing for `rcslice` inputs (e.g., '1' for the first item, '3' for the third). Ensure your end index includes the last desired element.
affects: All versions
gotchaWhen using multiple slice syntaxes (e.g., '1-2,4-5'), `rcslice` will insert a separator between the results of each individual slice operation. If not specified during `RowSlice` instantiation (e.g., `rs = RowSlice([''])`), the default behavior might lead to unintended formatting or empty lines in the output.
fix
Explicitly pass a list to the `RowSlice` constructor to define your separator, e.g., `rs = RowSlice(['---'])` for a single '---' line, or `rs = RowSlice([])` for no separator, or `rs = RowSlice(['', ''])` for two newlines.
affects: All versions
gotchaThe primary class is `RowSlice`, and its documentation emphasizes a 'special priority on row'. While column slicing is supported (e.g., '1.2-3.4'), complex interactions between row and column specifications in the slicing syntax may behave non-intuitively if not thoroughly understood from the documentation.
fix
Carefully review the 'Slicing syntax' section in the GitHub README for details on how row (r) and column (c) indices interact, especially when both are specified or omitted, and how 'e' (last row) behaves.
affects: All versions
Errors
Common errors & fixes
IndexError: list index out of range
Attempting to slice with 0-based indexing (e.g., '0-2' for the first three items) or requesting an index beyond the actual 1-based size of the list.
fix
Remember that `rcslice` uses 1-based indexing. For the first item, use '1'. For a list of 5 items, the last valid index is '5'. Ensure your slice range (e.g., '1-5') aligns with the 1-indexed length of your data.
Output list contains fewer or more elements than expected, or includes unexpected separator lines.
Misunderstanding the inclusive nature of the end index or the automatic separator insertion for multiple slices.
fix
If slicing '1-3', it includes elements at 1, 2, and 3. If combining slices (e.g., '1-2,4'), ensure `RowSlice` is instantiated with the desired separator behavior (e.g., `RowSlice([])` for no separator, `RowSlice(['---'])` for a visual separator).
AttributeError: 'list' object has no attribute 'split' or similar string manipulation error.
The `rcslice` library expects each item in the input list to be a 'sliceable' (e.g., a string that can be split for column operations). If you pass a list of non-string objects or objects that don't support `split`, column operations will fail.
fix
Ensure that if you are performing column-based slicing (e.g., '1.2'), the items within your input list are strings or objects that correctly implement string-like `split()` behavior.
Upgrade
Version history
1.1.0latest on PyPI · released Sep 27, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
rcslice — pip install rcslice · libregistry