Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Yelrose/linecache_light

Repository files navigation

linecache_light

A python package that can fast random access any lines in a large file without high memory cost.

Usage

It's avaiable to install linecache_light throught pip.

	pip install linecache_light

The basic usage is followed:

	from linecache_light import LinceCache
	linecache = LineCache('large_file.txt', cache_suffix='.cache')
	# This will create a cache file with suffix in your file location
	# Noticing it may cost a long time to cache the file since the LineCache will scan through the document.
	# If the cache file has already existed, it will reload the cache file in a much short time without scan through the document again.
	
	# Check the total number of lines
	print len(linecache)
	
	# Access the lines by line index
	print linecache[5]
	
	# Access the lines by slice
	print linecache[3:5]
	print linecache[-1]
	
	# Access the lines by a iterable list of index
	print linecache[[3,2,1,5]]

About

A python package that can fast random access any lines in a large file without high memory cost.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /