This release is a pre-release and may not be stable for production use.
Introduction
Lines is a simple program that allows you to manipulate lines of a file as if they were members of a set. It also provides a few other useful functions to analyse such files.
Set operations
Given two files
file1 containing
a b c d
and file2 with
c d e f
It’s possible to do things like
Unions
lines -u file1 file2
gives
a b c d e f
Intersections
lines -i file1 file2
gives
c d
Difference (All elements in file1 that are not in file2).
lines -d file1 file2
gives
a b
- Symmetric difference (All elements present in only one of the
sets).
lines -s file1 file2
gives
a b e f
Other Operations
These are a few other operations which I’ve found useful
Squeeze blanks
This operation squeezes out the blank lines in a file.
So, If you run lines –squeeze file1 where file1 looks like this
a b c
d
f
You’d get
a b c d f
Identify Patterns
This partitions the elements of the set into subsets all of whose members have an upper bound on the levenshtein distance from each other. This is useful to identify patterns in the input file.
So, if I have a file examples/f6 that looks like this
Archive.001-of-020.part Archive.002-of-020.part Archive.003-of-020.part Archive.004-of-020.part Archive.005-of-020.part Archive.006-of-020.part Archive.007-of-020.part .Archive.008-of-020.part.zbnrw Archive.009-of-020.part Archive.010-of-020.part Archive.011-of-020.part Archive.012-of-020.part Archive.013-of-020.part Archive.014-of-020.part Archive.015-of-020.part Archive.016-of-020.part Archive.017-of-020.part Archive.018-of-020.part Archive.019-of-020.part Archive.020-of-020.part
I can run python lines.py –patterns -l 5 examples/f6 and get
19 elements 1 elements - {‘.Archive.008-of-020.part.zbnrw’}
The -l 5 is to set the upper bound on the levenshtein distance to 5. The -p option allows us to specify an “outlier percentage”. If the number of elements in a subset is below this, it will print all the elements of the subset. This is useful to see the items that don’t match the general pattern in the file.
Metadata
Release files for lines 0.1.0-a
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lines-0.1.0-a.tar.gz | 2.6 kB | Details |
Release files / lines-0.1.0-a.tar.gz
| Download URL | lines-0.1.0-a.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec0ed344fcac1dc955e45f3a3cf40b88aa11187a85012b71aa41de0dbfbfe2dd
|
|
BLAKE2b-256 checksum How to use checksums |
5fe275c52414c13501b2b7886fcef7b2b3d5054ae141a1a00765b5d9a5f3d9fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |