detect-geocsv.js
function detectGeoCSV(buf) {
    var lines = buf.toString()
        .split(/\r\n|\r|\n/g)
        .filter(function(line) {
            return line !== '';
        });

    return lines.length > 0 &&
        // if the CSV file begins with {"type":, it's more likely
        // a GeoJSON file
        !lines[0].substring(0, 50).match(/^\s*\{\s*"type"\s*:/) &&
        detectGeometryField(lines[0]
            .split(detectSeparator(lines[0]))
            .map(function(header) {
                return header.replace(/"/g, '');
            }));

}
function detectGeoCSV(buf) {
    var lines = buf.toString()
        .split(/\r\n|\r|\n/g)
        .filter(function(line) {
            return line !== '';
        });

    return lines.length > 0 &&
        // if the CSV file begins with {"type":, it's more likely
        // a GeoJSON file
        !lines[0].substring(0, 50).match(/^\s*\{\s*"type"\s*:/) &&
        detectGeometryField(lines[0]
            .split(detectSeparator(lines[0]))
            .map(function(header) {
                return header.replace(/"/g, '');
            }));

}
Determine whether an input is a CSV file that could be
put on a map: that it has geographical information
that amounts to points or geography.
@param {string|Buffer} buf input, an upload that could be any format
@returns {boolean} whether the content is or is not geographic
@example
var detect = require('@mapbox/detect-geocsv');
var buffer = fs.readFileSync('path/to/data/file.csv');
var isgeocsv = detect(buffer);
assert.ok(isgeocsv);