okfn / messytables

Tools for parsing messy tabular data. This is now superseded by https://github.com/frictionlessdata/tabulator-py
http://messytables.readthedocs.io/
387 stars 110 forks source link

Add a sampling rate to the rowsets #162

Open ricecooker opened 7 years ago

ricecooker commented 7 years ago

When creating the sample for header and type guessing, in addition to a window (size of sample), can we add sampling rate? For example if sampling_rate = 0.01 for every 100 lines it reads, it'd only add 1 to the self._sample up until the len(self._sample) >= self.window?

This way it should work for both streaming and file loading applications. Those who are working off of files just need to divide their window by number of rows to get their sampling rate.

Motivation for this is I often find myself with very large CSV files that are sorted and guesses based on the first n rows of 20 million are often wrong.