<commit_before>// How to use:
// getValidation("Example,CSV,content\na,b,c\n")
//  .then(function(validation) {console.log(validation)})

function getValidation(content) {
  request = require('request');
  content = new Buffer(content).toString("base64");
  content = "editor.csv;data:text/csv;base64," + content;
  return new Promise(function(resolve, reject) {
    request.post("http://csvlint.io/package.json", { formData: {"files_data[]": content } }, function(error, response, body) {

      if (error) return reject(error);

      var packageURL = JSON.parse(response.body).package.url;
      var interval = setInterval(function() {
        request.get(packageURL + ".json", function(error, response, body) {
          try {
            var validationURL = JSON.parse(body).package.validations[0].url;
            clearInterval(interval);
            request.get(validationURL + ".json", function(error, response, body) {
              if (error) return reject(error);
              resolve(JSON.parse(body));
            });
          } catch(e) {}
        });
      }, 1000);

    });
  });
}

function validate() {
  data = hot.getData().map(function(d) { return d.join(",") }).join("\n")
  json_data = '{"version":"0.1","licence":"http://opendatacommons.org/licenses/odbl/","validation":{"url":"http://csvlint.io/validation/55ca092f63737668de000069","source":"http://theodi.github.io/hot-drinks/hot-drinks.csv","state":"warnings","errors":[],"warnings":[{"type":"malformed_header","category":"schema","row":1,"col":null}],"info":[{"type":"assumed_header","category":"structure","row":null,"col":null},{"type":"nonrfc_line_breaks","category":"structure","row":null,"col":null}],"standardisedCSV":"http://csvlint.io/validation/55ca092f63737668de000069.csv","badges":{"svg":"http://csvlint.io/validation/55ca092f63737668de000069.svg","png":"http://csvlint.io/validation/55ca092f63737668de000069.png"}}}'
  json_data_2 = getValidation("Interns,LOL,,,,a\nas,f").then(function(json_validation) {
    errors = json_validation.validation.errors
    warnings = json_validation.validation.warnings
    info_messages = json_validation.validation.info
    console.error(errors)
    console.warn(warnings)
    console.info(info_messages);
  });
}<commit_msg>Got rid of some rough work<commit_after>// How to use:
// getValidation("Example,CSV,content\na,b,c\n")
//  .then(function(validation) {console.log(validation)})

function getValidation(content) {
  request = require('request');
  content = new Buffer(content).toString("base64");
  content = "editor.csv;data:text/csv;base64," + content;
  return new Promise(function(resolve, reject) {
    request.post("http://csvlint.io/package.json", { formData: {"files_data[]": content } }, function(error, response, body) {

      if (error) return reject(error);

      var packageURL = JSON.parse(response.body).package.url;
      var interval = setInterval(function() {
        request.get(packageURL + ".json", function(error, response, body) {
          try {
            var validationURL = JSON.parse(body).package.validations[0].url;
            clearInterval(interval);
            request.get(validationURL + ".json", function(error, response, body) {
              if (error) return reject(error);
              resolve(JSON.parse(body));
            });
          } catch(e) {}
        });
      }, 1000);

    });
  });
}

function validate() {
  data = hot.getData().map(function(d) { return d.join(",") }).join("\n")
  getValidation(data).then(function(json_validation) {
    errors = json_validation.validation.errors
    warnings = json_validation.validation.warnings
    info_messages = json_validation.validation.info
    console.error(errors)
    console.warn(warnings)
    console.info(info_messages);
  });
}
{'fraction_non_alphanumeric': 0.1777012711864407, 'fraction_numerical': 0.025953389830508475, 'mean_word_length': 4.002649006622517, 'pattern_counts': {'":': 27, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5071223', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1132, 'n_words': 162}