org-report-stats/base_convert_to_activities_...

65 lines
1.9 KiB
JavaScript

import fs from "node-fs";
import {headersTsv, writeFileInOuputFolderFromJsonObject} from "./utils.mjs";
/**
convertir un json représentant toutes les tâches orgmode en un json rangé par dates
**/
const sourceFileName = 'export_all_tasks.org_parsed'
const outputAbsolutePath = '/home/tykayn/Nextcloud/ressources/social sorting/output/';
const outputFileNameJson = sourceFileName + '.json';
const sourceFilePath = "/home/tykayn/Nextcloud/ressources/social sorting/" + outputFileNameJson
const outputFileName = sourceFileName + '.tsv';
const events = [headersTsv];
let counter = 0;
let max_count = 10000
function parseJsonFile() {
fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
const json_content = JSON.parse(data);
console.log(outputAbsolutePath + outputFileNameJson, json_content.tasks_list.length)
// do parse json content and add to tsv lines
data.forEach(item => {
if (counter < max_count) {
counter++;
console.log('item', item)
// TODO ajust lines
let newLine =
// item.visit_count + '\t' +
// item.title + '\t' +
// item.description + '\t' +
// item.preview_image_url + '\t' +
'' + '\t' +
// 'firefox_place' + '\t' +
'' + '\t' +
'' + '\t' +
// mydate + '\t' +
'' + '\t' +
'' + '\t'
url + '\t' +
''
// console.log('mydate',stamp, mydate)
events.push(newLine)
}
})
console.log('events', events.length)
writeFileInOuputFolderFromJsonObject(outputFileName, events.join("\n")).then(r => console.log('r', r))
})
}
parseJsonFile()