{ "info": { "author": "Nicholas C Pandolfi", "author_email": "npandolfi@wpi.edu", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Topic :: System :: Filesystems", "Topic :: Utilities" ], "description": "Overview\r\n--------\r\n\r\nlinereader is a python package that gives the user the ability to access\r\nfiles with ease. The linereader package offers several new powerful ways\r\nof using files.\r\n\r\nTwo main new types of file handles are added to linereader:\r\n\r\n1- ``copen``, a cache based solution to random file access and dynamic\r\nprocessing\r\n\r\n2- ``dopen``, a slower but universal way of random file access and\r\ndynamic processing\r\n\r\n\r\nRandom file access and processing with a cache\r\n----------------------------------------------\r\n\r\nlinereader was meant as a direct substitute to python\u2019s built-in\r\nlinecache module. With linereader, cached entries are loaded using less\r\nmemory, and are around 12% faster to access than those of linecache.\r\nThere are extra utility functions added to linereader to aid in the\r\nmanipulation of the global cache.\r\n\r\nIf one wants to get a upgrade of linecache, linereader offers a\r\npolymorphic ``getline`` function, where:\r\n\r\n``from linecache import getline`` \r\ncan be replaced by:\r\n``from linereader import getline``\r\n\r\nand both behave the same way, loading a file\u2019s contents into cached\r\nmemory.\r\n\r\nAn example of this usage would be as follows:\r\n\r\n::\r\n\r\n from linereader import getline\r\n\r\n filename = 'C:/Python34/testfile.txt'\r\n\r\n line_1 = getline(filename, 1)\r\n line_2 = getline(filename, 2)\r\n\r\n print(line_1, line_2)\r\n\r\nIn addition to ``getline``, linereader also contains ``getonce``, and\r\n``copen``, which are used as solutions to cache based file access.\r\n\r\n\r\nRandom file access and processing without loading into memory\r\n-------------------------------------------------------------\r\n\r\nThe problem with file accessing methods that load the entire file into a\r\ncache, is that they only work on small files. Usually, a 5GB file cannot\r\nbe loaded into memory without the python interpreter crashing. Even if a\r\nfile can be loaded, it slows down the session, and eats up useful\r\nmemory. A new file handle that was added into linereader,\r\n``linereader.dopen``, works around this problem and can access any line\r\nfrom any size text/logging/data file with consistency. The speed to\r\nwhich the file can be accessed is proportional to the amount of\r\ncharacters that are being read. There exists a slight python overhead\r\nwhen accessing any file line, that takes around 31 microseconds. Using a\r\n10 GB test file, a line consisting of one character was returned in 31\r\nmicroseconds, and a line containing 135 characters was returned in 97\r\nmicroseconds.\r\n\r\ndopen\u2019s special internals allow for near-identical return speeds on same\r\nlength lines within the same file. This means that if file a was loaded\r\nusing dopen, and lines 368 and 290 both contained the same amount of\r\ncharacters, they would take almost the same exact time to return. The\r\nway that the dopen handle was made, allows for the ability to quickly\r\njump from one position in a file to the next. Conventional methods of\r\nreading from a file have to iterate through all the characters or lines\r\nand silently read the content that the user doesn\u2019t want, to pass over\r\nand get to the the content that they need.\r\n\r\nA simple example of dopen\u2019s usage results as follows:\r\n\r\n::\r\n\r\n import linereader\r\n\r\n filename = 'C:/Python34/NEWS.txt'\r\n file = linereader.dopen(filename)\r\n\r\n header = file.getline(1) + file.getline(2)\r\n line_500 = file.getline(500)\r\n line_38 = file.getline(38)\r\n from_38_to_500 = file.getlines(38, 500)\r\n\r\nThe usage of dopen gets very advanced, and is actually completely\r\npolymorphic with the regular ``open()`` handle:\r\n\r\n::\r\n\r\n import linereader\r\n\r\n filename = 'C:/Python34/README.txt'\r\n file = linereader.dopen(filename)\r\n\r\n file.seek(50)\r\n chars = file.read(10)\r\n file.seek(1337)\r\n\r\n chars += file.read(80)\r\n chars += file.readline()\r\n\r\n rest = file.readlines()\r\n\r\nIn addition, dopen also offers powerful methods for the navigation of\r\nthe file pointers:\r\n\r\n::\r\n\r\n from linereader import dopen\r\n file = dopen('C:/Python34/README.txt')\r\n\r\n file.seekline(58)\r\n line_58 = file.readline()\r\n next_10_lines = file.readnext(10)\r\n line_67 = file.getline(67)\r\n\r\nContact\r\n-------\r\n\r\nIf you have any questions or issues regarding linereader, please contact me at:\r\n\r\n-npandolfi@wpi.edu", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/nickpandolfi/linereader", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nickpandolfi/linereader", "keywords": "", "license": "The MIT License (MIT)", "maintainer": "", "maintainer_email": "", "name": "linereader", "package_url": "https://pypi.org/project/linereader/", "platform": "CROSS-PLATFORM", "project_url": "https://pypi.org/project/linereader/", "project_urls": { "Download": "https://github.com/nickpandolfi/linereader", "Homepage": "https://github.com/nickpandolfi/linereader" }, "release_url": "https://pypi.org/project/linereader/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "Gives Python the ability to randomly access any chunk of a file quickly, without loading any content into memory, and implements two new dynamic types of file handles.", "version": "1.0.0" }, "last_serial": 2011529, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "d2d71b79eac5e0eb80fe5043d91d8e2a", "sha256": "1ed1d11034e7e59d463264605dd71a791e762aebfe3adc5637f8c2076b3de728" }, "downloads": -1, "filename": "linereader-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d2d71b79eac5e0eb80fe5043d91d8e2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5324, "upload_time": "2014-05-26T19:10:46", "url": "https://files.pythonhosted.org/packages/a2/dd/3b99fda477a51c54f5544b9074534e03991e17ac713fd1cc2640ffc8e38c/linereader-1.0.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "76c31eeec8140a4e94c5710973aa788b", "sha256": "4b2bcb6cad7f830bb4796276dabee3abb4900bff0638182f5595130441deb2a0" }, "downloads": -1, "filename": "linereader-1.0.0.win32.exe", "has_sig": false, "md5_digest": "76c31eeec8140a4e94c5710973aa788b", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 199134, "upload_time": "2014-05-26T19:13:00", "url": "https://files.pythonhosted.org/packages/54/d5/41d22b2d5ad50d054c1843e73f0c85292342784e915ca8fe13efed88ab8e/linereader-1.0.0.win32.exe" }, { "comment_text": "", "digests": { "md5": "137d3c076c3db9f9132d61268f1ef8e3", "sha256": "b2e6931bc2acce64354c368a6285a0c6eccb100c81b2e575e87cc618a881b77c" }, "downloads": -1, "filename": "linereader-1.0.0.zip", "has_sig": false, "md5_digest": "137d3c076c3db9f9132d61268f1ef8e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8563, "upload_time": "2014-05-26T19:10:44", "url": "https://files.pythonhosted.org/packages/95/c7/a64aed2e11bfafb068397fa59a43e0e0ed7615d5c718631d92673dad50a4/linereader-1.0.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d2d71b79eac5e0eb80fe5043d91d8e2a", "sha256": "1ed1d11034e7e59d463264605dd71a791e762aebfe3adc5637f8c2076b3de728" }, "downloads": -1, "filename": "linereader-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d2d71b79eac5e0eb80fe5043d91d8e2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5324, "upload_time": "2014-05-26T19:10:46", "url": "https://files.pythonhosted.org/packages/a2/dd/3b99fda477a51c54f5544b9074534e03991e17ac713fd1cc2640ffc8e38c/linereader-1.0.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "76c31eeec8140a4e94c5710973aa788b", "sha256": "4b2bcb6cad7f830bb4796276dabee3abb4900bff0638182f5595130441deb2a0" }, "downloads": -1, "filename": "linereader-1.0.0.win32.exe", "has_sig": false, "md5_digest": "76c31eeec8140a4e94c5710973aa788b", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 199134, "upload_time": "2014-05-26T19:13:00", "url": "https://files.pythonhosted.org/packages/54/d5/41d22b2d5ad50d054c1843e73f0c85292342784e915ca8fe13efed88ab8e/linereader-1.0.0.win32.exe" }, { "comment_text": "", "digests": { "md5": "137d3c076c3db9f9132d61268f1ef8e3", "sha256": "b2e6931bc2acce64354c368a6285a0c6eccb100c81b2e575e87cc618a881b77c" }, "downloads": -1, "filename": "linereader-1.0.0.zip", "has_sig": false, "md5_digest": "137d3c076c3db9f9132d61268f1ef8e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8563, "upload_time": "2014-05-26T19:10:44", "url": "https://files.pythonhosted.org/packages/95/c7/a64aed2e11bfafb068397fa59a43e0e0ed7615d5c718631d92673dad50a4/linereader-1.0.0.zip" } ] }