diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/base_convert_to_activities_tsv.mjs b/base_convert_to_activities_tsv.mjs index 46408a2..851ec83 100644 --- a/base_convert_to_activities_tsv.mjs +++ b/base_convert_to_activities_tsv.mjs @@ -1,7 +1,6 @@ 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 **/ @@ -10,53 +9,67 @@ const outputAbsolutePath = '/home/tykayn/Nextcloud/ressources/social sorting/out const outputFileNameJson = sourceFileName + '.json'; const sourceFilePath = "/home/tykayn/Nextcloud/ressources/social sorting/" + outputFileNameJson -const outputFileName = sourceFileName + '.tsv'; + +const outputFileName = outputAbsolutePath + sourceFileName + '.tsv'; + +// const separator_char= ";" +const separator_char = '\t' const events = [headersTsv]; let counter = 0; -let max_count = 10000 +let max_count = 2000 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 => { + json_content.tasks_list.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) + + let newLine; + newLine = "" + + // 0 'amount\t' + + '' + separator_char + + // 1 'content\t' + + item.corpus ?? '' + ' ' + separator_char + + // 2 'description\t' + + item.header + ' '+ separator_char + + // 3 'destination\t' + + '' + separator_char + + // 4 'end\t' + + item?.dates?.CLOSED+ ' ' + separator_char + + // 5 'kind of activity\t' + + '' + separator_char + + // 6 'person\t' + + '' + separator_char + + // 7 'place\t' + + '' + separator_char + + // 8 'source\t' + + 'orgmode_all_tasks' + ' '+ separator_char + + // 9 'start\t' + + item?.dates?.CREATED + ' ' + separator_char + + // 10 'unique id\t' + + '' + separator_char + + // 11 'url\t' + '' + separator_char + ''; + events.push(newLine) } }) console.log('events', events.length) - writeFileInOuputFolderFromJsonObject(outputFileName, events.join("\n")).then(r => console.log('r', r)) + writeFileInOuputFolderFromJsonObject(outputFileName, events.join("\n")) + .then(r => console.log('r', r)) }) } diff --git a/json_orgmode_sort_by_dates_to_activities_tsv.mjs b/json_orgmode_sort_by_dates_to_activities_tsv.mjs index c504854..e90d3d4 100644 --- a/json_orgmode_sort_by_dates_to_activities_tsv.mjs +++ b/json_orgmode_sort_by_dates_to_activities_tsv.mjs @@ -1,7 +1,6 @@ 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 **/ @@ -10,55 +9,69 @@ const outputAbsolutePath = '/home/tykayn/Nextcloud/ressources/social sorting/out const outputFileNameJson = sourceFileName + '.json'; const sourceFilePath = "/home/tykayn/Nextcloud/ressources/social sorting/" + outputFileNameJson -const outputFileName = sourceFileName + '.tsv'; + +const outputFileName = outputAbsolutePath + sourceFileName + '.tsv'; + +// const separator_char= ";" +const separator_char = '\t' const events = [headersTsv]; let counter = 0; -let max_count = 10000 +let max_count = 2000 function parseJsonFile() { - fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) { + fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) { + if (err) { + return console.log(err); + } + const json_content = JSON.parse(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 + json_content.tasks_list.forEach(item => { + if (counter < max_count) { + counter++; - // do parse json content and add to tsv lines - data.forEach(item => { + // TODO ajust lines - if (counter < max_count) { - counter++; - console.log('item', item) + let newLine; + newLine = "" + + // 0 'amount\t' + + '' + separator_char + + // 1 'content\t' + + item.corpus ?? '' + ' ' + separator_char + + // 2 'description\t' + + item.header + ' '+ separator_char + + // 3 'destination\t' + + '' + separator_char + + // 4 'end\t' + + item?.dates?.CLOSED+ ' ' + separator_char + + // 5 'kind of activity\t' + + '' + separator_char + + // 6 'person\t' + + '' + separator_char + + // 7 'place\t' + + '' + separator_char + + // 8 'source\t' + + 'orgmode_all_tasks' + ' '+ separator_char + + // 9 'start\t' + + item?.dates?.CREATED + ' ' + separator_char + + // 10 'unique id\t' + + '' + separator_char + + // 11 'url\t' + '' + separator_char + ''; - // 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) - } - }) + events.push(newLine) + } + }) - console.log('events', events.length) - // writeFileInOuputFolderFromJsonObject(outputFileName, events.join("\n")).then(r => console.log('r', r)) + console.log('events', events.length) + writeFileInOuputFolderFromJsonObject(outputFileName, events.join("\n")) + .then(r => console.log('r', r)) - }) + }) } parseJsonFile() diff --git a/utils.mjs b/utils.mjs index fab4002..c5639aa 100644 --- a/utils.mjs +++ b/utils.mjs @@ -1,33 +1,34 @@ import fs from "node-fs"; export const headersTsv = 'amount\t' + - 'content\t' + - 'description\t' + - 'destination\t' + - 'end\t' + - 'kind of activity\t' + - 'person\t' + - 'place\t' + - 'source\t' + - 'start\t' + - 'unique id\t' + - 'url\t' - + 'content\t' + + 'description\t' + + 'destination\t' + + 'end\t' + + 'kind of activity\t' + + 'person\t' + + 'place\t' + + 'source\t' + + 'start\t' + + 'unique id\t' + + 'url\t' +const outputAbsolutePath = '/home/tykayn/Nextcloud/ressources/social sorting/output/'; export async function writeFileInOuputFolderFromJsonObject(fileName, jsonObjectThing) { + // console.log('statistics.dates', statistics.dates) - return await fs.writeFile( - `${outputAbsolutePath}${fileName}`, - JSON.stringify(jsonObjectThing), - "utf8", - (err) => { - if (err) { - console.log(`Error writing file: ${err}`); - } else { - console.log(`File ${fileName} is written successfully!`); - } - } - ); + return await fs.writeFile( + `${fileName}`, + JSON.stringify(jsonObjectThing), + "utf8", + (err) => { + if (err) { + console.log(`Error writing file: ${err}`); + } else { + console.log(`File ${fileName} is written successfully!`); + } + } + ); }