<commit_before>#!/usr/bin/nodejs

const chalk = require('chalk');
const https = require('https');
const config = require('./Util/config');
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');

const url = 'https://blockchain.info/pt/charts/market-price?showDataPoints=false&timespan=all&show_header=true&daysAverageString=1&scale=0&format=csv&address=';
const output_file_path = path.join(config.outputFolder, config.name);

mkdirp.sync(config.outputFolder);

var request = https.get(url, function(response) {
    var final_data = "";

    response.on('data', function(data) {
        final_data += data.toString();
    });

    response.on('end', function() {
        fs.writeFile(
            output_file_path, //destination
            final_data, //content
            (err) => { //callback
                if (err) {
                    console.log(chalk.red("FAILED TO SAVE DATA"));
                    console.log(err);
                } else {
                    console.log(chalk.green("SAVED DATA ON ") + output_file_path);
                }
            });
    });

});

request.on('error', function(e) {<commit_msg>Changed bitcoin market price api to be compatible with existing code<commit_after>#!/usr/bin/nodejs

const chalk = require('chalk');
const http = require('http');
const config = require('./Util/config');
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');

function today() {
	function formatNumber(number) {
		if (number < 10) {
			number =  '0' + number;
		} else {
			number = '' + number;
		}
		return number;
	}
	var dateObj = new Date();
	var month = formatNumber(dateObj.getUTCMonth() + 1); //months from 1-12
	var day = formatNumber(dateObj.getUTCDate());
	var year = dateObj.getUTCFullYear();

	return year + "-" + month + "-" + day;
}

const url = 'http://api.coindesk.com/v1/bpi/historical/close.csv?start=2010-07-18&end=' + today() + '&index=USD';
const output_file_path = path.join(config.outputFolder, config.name);

mkdirp.sync(config.outputFolder);

var request = http.get(url, function(response) {
    var final_data = "";

    response.on('data', function(data) {
        final_data += data.toString();
    });

    response.on('end', function() {
        fs.writeFile(
            output_file_path, //destination
            final_data, //content
            (err) => { //callback
                if (err) {
                    console.log(chalk.red("FAILED TO SAVE DATA"));
                    console.log(err);
                } else {
                    console.log(chalk.green("SAVED DATA ON ") + output_file_path);
                }
            });
    });

});

request.on('error', function(e) {
{'fraction_non_alphanumeric': 0.15859030837004406, 'fraction_numerical': 0.006607929515418502, 'mean_word_length': 2.6044973544973544, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '2265888', 'n_tokens_mistral': 870, 'n_tokens_neox': 827, 'n_words': 168}