Split a huge file in to equal parts

Introduction

How to split a file in to equal parts without knowing the number of records in the input file?

Background

Suppose you don't know how many records are in a dataset, but you want to divide the records as equal as possible among the output datasets. We can split a file into equal number parts by using ICETOOL with a small keyword SPLIT / SPLITBY. The all output files will have same number of records. The below code split the file into three equal parts.