<commit_before>#!/usr/bin/env node

var path = require('path');

var usage = 'usage:';
usage += '\n  mapnik-inspect.js <datasource> (.shp|.json|.geojson|.kml|.sqlite|.gml|.vrt|.csv)';
usage += '\n  mapnik-inspect.js <stylesheet> (.xml)';
usage += '\n  mapnik-inspect.js <projection> (.prj)';
usage += '\n  mapnik-inspect.js <zipfile> (.zip)';

var obj = process.ARGV[2];
if (!obj) {
   console.log(usage);
   process.exit(1);
}

if (!path.existsSync(obj)) {
    console.log(obj + ' does not exist');
    process.exit(1);
}

var mapnik = require('mapnik');

console.log(obj);

if (/.shp$/.test(obj)) {
    var opened = new mapnik.Datasource({type: 'shape', file: obj});
    console.log(opened.describe());
}
else if ((/.json$/.test(obj))
         || (/.geojson$/.test(obj))
         || (/.kml$/.test(obj))
         || (/.sqlite3$/.test(obj))
         || (/.db$/.test(obj))
         || (/.gml$/.test(obj))
         || (/.vrt$/.test(obj))
         || (/.csv$/.test(obj))
         || (/.dbf$/.test(obj))
        ) {
    var opened = new mapnik.Datasource({type: 'ogr', file: obj, 'layer_by_index': 0});
    console.log(opened.describe());
}
else if (/.xml$/.test(obj)) {
    var map = new mapnik.Map(1,1);
    map.load(obj);
    console.log(map.layers());
}
else if (/.prj$/.test(obj)) {
    var srs = require('srs');
    console.log(srs.parse(obj));
}
else if (/.zip$/.test(obj)) {
    var zip = require('zipfile');
    var zf = new zip.ZipFile(obj);
    console.log(zf);
}
else {
    console.log('Error: unsupported file, unable to inspect');
    process.exit(1);
}<commit_msg>output first feature<commit_after>#!/usr/bin/env node

var path = require('path');

var usage = 'usage:';
usage += '\n  mapnik-inspect.js <datasource> (.shp|.json|.geojson|.kml|.sqlite|.gml|.vrt|.csv)';
usage += '\n  mapnik-inspect.js <stylesheet> (.xml)';
usage += '\n  mapnik-inspect.js <projection> (.prj)';
usage += '\n  mapnik-inspect.js <zipfile> (.zip)';

var obj = process.ARGV[2];
if (!obj) {
   console.log(usage);
   process.exit(1);
}

if (!path.existsSync(obj)) {
    console.log(obj + ' does not exist');
    process.exit(1);
}

var mapnik = require('mapnik');

console.log(obj);

if (/.shp$/.test(obj)) {
    var opened = new mapnik.Datasource({type: 'shape', file: obj});
    console.log('Description -->');
    console.log(opened.describe());
    console.log('First feature --> ');
    console.log(opened.features().slice(0,1));
}
else if ((/.json$/.test(obj))
         || (/.geojson$/.test(obj))
         || (/.kml$/.test(obj))
         || (/.sqlite3$/.test(obj))
         || (/.db$/.test(obj))
         || (/.gml$/.test(obj))
         || (/.vrt$/.test(obj))
         || (/.csv$/.test(obj))
         || (/.dbf$/.test(obj))
        ) {
    var opened = new mapnik.Datasource({type: 'ogr', file: obj, 'layer_by_index': 0});
    console.log('Description -->');
    console.log(opened.describe());
    console.log('First feature --> ');
    console.log(opened.features().slice(0,1));
}
else if (/.xml$/.test(obj)) {
    var map = new mapnik.Map(1,1);
    map.load(obj);
    console.log(map.layers());
}
else if (/.prj$/.test(obj)) {
    var srs = require('srs');
    console.log(srs.parse(obj));
}
else if (/.zip$/.test(obj)) {
    var zip = require('zipfile');
    var zf = new zip.ZipFile(obj);
    console.log(zf);
}
else {
    console.log('Error: unsupported file, unable to inspect');
    process.exit(1);
}
{'fraction_non_alphanumeric': 0.23934137018523963, 'fraction_numerical': 0.005880623346074684, 'mean_word_length': 2.8354002254791433, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '770805', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1291, 'n_words': 234}