emat/util/xmle/file_util.py
def head(filename, n=10):
	"""Print the top N lines of a file from disk.

	The file can be gzipped, if it has a .gz extension.
	"""
	print("[HEAD {}] {}".format(n, filename))
	if filename[-3:].casefold() == '.gz':
		with gzip.open(filename, 'rt') as previewfile:
			print(*(next(previewfile) for x in range(n)))
	else:
		with open(filename, 'r') as f:
			for linenumber in range(n):
				line = f.readline()
				print(line)
	print("[END HEAD]")
Print the top N lines of a file from disk.

	The file can be gzipped, if it has a .gz extension.
	
Print the top N lines of a file from disk.
The file can be gzipped, if it has a .gz extension.
Print the top N lines of a file from disk . The file can be gzipped if it has a . gz extension .
def head(filename, n=10):
	print("[HEAD {}] {}".format(n, filename))
	if filename[-3:].casefold() == '.gz':
		with gzip.open(filename, 'rt') as previewfile:
			print(*(next(previewfile) for x in range(n)))
	else:
		with open(filename, 'r') as f:
			for linenumber in range(n):
				line = f.readline()
				print(line)
	print("[END HEAD]")
def head ( filename , n = 10 ) : print ( "[HEAD {}] {}" . format ( n , filename ) ) if filename [ - 3 : ] . casefold ( ) == '.gz' : with gzip . open ( filename , 'rt' ) as previewfile : print ( * ( next ( previewfile ) for x in range ( n ) ) ) else : with open ( filename , 'r' ) as f : for linenumber in range ( n ) : line = f . readline ( ) print ( line ) print ( "[END HEAD]" )
Print the top N lines of a file from disk.
Print the top N lines of a file from disk .
"""Print the top N lines of a file from disk.

	The file can be gzipped, if it has a .gz extension.
	"""
filename
n