Skip to main content

Separate two files into three files, each containing lines observed in both files/first file only/second file only. Programmed using Cython.

Project description

The filediffs package

Build Status company filediffs takes two files and separates them into

  1. lines found in both files
  2. lines found only in file 1
  3. lines found only in file 2

Code inspired by https://www.splinter.com.au/reconcilingcomparing-huge-data-sets-with-c/ and implemented using Cython

Lines found in both files are not kept in memory but written to disk every 5.000.000 lines to preserve memory.

This way, even very large files can be separated. Only the diff has to fit in memory.

1. Installation

1.1 Pypi:

filediffs is available on pypi and can therefore be installed via pip

pip install filediffs

Currently, only wheels for Linux are build using manylinux.

On other OS, please install the package as described in the following section.

1.2 Github:

You can clone the package from Github and transpile the Cython code to C++ on your machine.

For Dependency management, Pipenv is used.

The Pipfile defines the python version and package requirements.

You can create a virtual environment for the package with Pipenv by

  1. installing pipenv pip install pipenv
  2. calling pipenv install to install from Pipfile.lock

The file build_cython_setup.py defines the cython build process.

The cpp files can be build using pipenv run python build_cython_setup.py build_ext --inplace.

2. Usage:

2.1 Interactive in Python

The file_diffs function requires two arguments with the path to the files you wish to compare.

In addition, three optional output arguments can be passed to the functions, defining the output file where to save the lines present only in the first / second or in both input files. If the output arguments are not passed to the function, the output will be saved into the working directory in three files.

from filediffs.filediffs import file_diffs
lines_only_in_file_1, lines_only_in_file_2 = file_diffs(
    filename_1=b'path/to/file1.txt',
    filename_2=b'path/to/file2.txt',
    outpath_lines_present_in_both_files=b'output_path/to/lines_in_both.txt',
    outpath_lines_present_only_in_file1=b'output_path/to/lines_only_in_file1.txt',
    outpath_lines_present_only_in_file2=b'output_path/to/lines_only_in_file2.txt',
)

To use the function in interaction with cython, the file paths have to passed to the function currently as bytestrings.

2.2 From the terminal

Inside the package directory, an example script filediffs_script.py is provided.

It can be used to separate files from the terminal:

# To separate two files, simply pass the filepath to `filediffs/filediffs_script.py`
python filediffs/filediffs_script.py filediffs/tests/data/file_1.txt filediffs/tests/data/file_2.txt

# If you want to define the filenames of the separated ouput files, optional arguments are provided for the script. 
python filediffs/filediffs_script.py filediffs/tests/data/file_1.txt filediffs/tests/data/file_2.txt --out_filename_both out_both.txt --out_filename_only_in_file1 out_file1_only.txt --out_filename_only_in_file2 out_file2_only.txt

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

filediffs-0.1.4.tar.gz (5.3 kB view details)

Uploaded Source

Built Distributions

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

filediffs-0.1.4-cp39-cp39-manylinux2010_x86_64.whl (140.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

filediffs-0.1.4-cp39-cp39-manylinux1_x86_64.whl (92.6 kB view details)

Uploaded CPython 3.9

filediffs-0.1.4-cp38-cp38-manylinux2010_x86_64.whl (144.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

filediffs-0.1.4-cp38-cp38-manylinux1_x86_64.whl (95.3 kB view details)

Uploaded CPython 3.8

filediffs-0.1.4-cp37-cp37m-manylinux2010_x86_64.whl (136.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

filediffs-0.1.4-cp37-cp37m-manylinux1_x86_64.whl (94.0 kB view details)

Uploaded CPython 3.7m

filediffs-0.1.4-cp36-cp36m-manylinux2010_x86_64.whl (138.6 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

filediffs-0.1.4-cp36-cp36m-manylinux1_x86_64.whl (92.8 kB view details)

Uploaded CPython 3.6m

File details

Details for the file filediffs-0.1.4.tar.gz.

File metadata

  • Download URL: filediffs-0.1.4.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2d6de637cb661cbf42ff90c0b55fd97e8c2e5dae7957ccfb36d10fdfa9f9d73e
MD5 60377a99ce1b38a77e7d55c920d439c2
BLAKE2b-256 8a7cf614705105bee5374f5d17b2a0a0e38e55f6607d3fc5b0e5dcc037877ebe

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 140.1 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 79ead039ee160c8cf4e5580349479c7097dd4ba0af96727d42b10fd41ae249a5
MD5 cc994e01bc121077142abb52f961d0f8
BLAKE2b-256 0cb330ae9d0d94dca094a5a9a37f44dcfd93a4f304a6fe3553050a3bcecaad47

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 92.6 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 51ac21c8bd390ed016bb0297796186d52d6104dacecaa60948b3ef8ed08c4e39
MD5 47522a01e8675abf5da150b5840fa56a
BLAKE2b-256 c030cd9537144e83e45eb909bd89f3fe7d4f2efb9f48e64e625d218b41ce454d

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 144.1 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 515a271487aa29d9d55813fbe3a79592cd9632f76edf71371fb44248799ba05b
MD5 e14a00983117f3737d2c9b36eac0fd5e
BLAKE2b-256 88bdf5422526e16b0a63dfecf7db444688f80cb552f9f493c7a7ea63986bc02f

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.3 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 41759eccc03d036f5e6c42c24926ce789a5e698ec7fe325b2e10ce2d30a410e8
MD5 febece01f3f9ffa13ad9a6b84858ecc5
BLAKE2b-256 e9b863321c2a8721559d5794207f0bcbf5b556e6304501238a09c3a68b88af5d

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 136.2 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3c62888f3ebcdd4e31f5f14084e179c85b8ff86cd399e93f221fd75877ffd736
MD5 68a22303665fad640d774c3972c9bb38
BLAKE2b-256 26969e404516ab0b6e507a587cd7be35d387ea0dc9b8d291bffa81c27d1b4260

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 94.0 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8bdcb14f39c4ae263227375b56acdfb54f34ee061295e847f76c8774f4dc7461
MD5 47003b0e9a7432d444b7669db7ade557
BLAKE2b-256 e41793f096fe3669867f08180242a6a809afce1877064e37cae8da726fab5880

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 138.6 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5c8b5d5958821c379856f3102f1f42aa0d07e4d7730da3d1c7057f648d439bed
MD5 368f06708dc0f982cbfd2b9f5883d438
BLAKE2b-256 544ef1a5f80059adb178ff83099377aa3ef1b0792d29a589f1b06f66735adee8

See more details on using hashes here.

File details

Details for the file filediffs-0.1.4-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: filediffs-0.1.4-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 92.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for filediffs-0.1.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0d871674286393899e1f2c46e0147638a41abb95a42c1e8068b5887777ec84b7
MD5 dd6a88789a52a05e7f74b19c4d0ae3d0
BLAKE2b-256 09cc9028761e024548c439600b61c30df515b630152abd4165c9ea24aaebcde5

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