up convert from orgmode to tsv
This commit is contained in:
parent
48420bb7fe
commit
e2fae4d826
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
|
@ -1,7 +1,6 @@
|
||||||
import fs from "node-fs";
|
import fs from "node-fs";
|
||||||
import {headersTsv, writeFileInOuputFolderFromJsonObject} from "./utils.mjs";
|
import {headersTsv, writeFileInOuputFolderFromJsonObject} from "./utils.mjs";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
convertir un json représentant toutes les tâches orgmode en un json rangé par dates
|
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 outputFileNameJson = sourceFileName + '.json';
|
||||||
|
|
||||||
const sourceFilePath = "/home/tykayn/Nextcloud/ressources/social sorting/" + outputFileNameJson
|
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];
|
const events = [headersTsv];
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
let max_count = 10000
|
let max_count = 2000
|
||||||
|
|
||||||
function parseJsonFile() {
|
function parseJsonFile() {
|
||||||
|
|
||||||
fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) {
|
fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) {
|
||||||
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
const json_content = JSON.parse(data);
|
const json_content = JSON.parse(data);
|
||||||
console.log(outputAbsolutePath + outputFileNameJson, json_content.tasks_list.length)
|
|
||||||
|
|
||||||
|
|
||||||
// do parse json content and add to tsv lines
|
// do parse json content and add to tsv lines
|
||||||
data.forEach(item => {
|
json_content.tasks_list.forEach(item => {
|
||||||
|
|
||||||
if (counter < max_count) {
|
if (counter < max_count) {
|
||||||
counter++;
|
counter++;
|
||||||
console.log('item', item)
|
|
||||||
|
|
||||||
// TODO ajust lines
|
// TODO ajust lines
|
||||||
let newLine =
|
|
||||||
// item.visit_count + '\t' +
|
let newLine;
|
||||||
// item.title + '\t' +
|
newLine = "" +
|
||||||
// item.description + '\t' +
|
// 0 'amount\t' +
|
||||||
// item.preview_image_url + '\t' +
|
'' + separator_char +
|
||||||
'' + '\t' +
|
// 1 'content\t' +
|
||||||
// 'firefox_place' + '\t' +
|
item.corpus ?? '' + ' ' + separator_char +
|
||||||
'' + '\t' +
|
// 2 'description\t' +
|
||||||
'' + '\t' +
|
item.header + ' '+ separator_char +
|
||||||
// mydate + '\t' +
|
// 3 'destination\t' +
|
||||||
'' + '\t' +
|
'' + separator_char +
|
||||||
'' + '\t'
|
// 4 'end\t' +
|
||||||
url + '\t' +
|
item?.dates?.CLOSED+ ' ' + separator_char +
|
||||||
''
|
// 5 'kind of activity\t' +
|
||||||
// console.log('mydate',stamp, mydate)
|
'' + 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)
|
events.push(newLine)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('events', events.length)
|
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))
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import fs from "node-fs";
|
import fs from "node-fs";
|
||||||
import {headersTsv, writeFileInOuputFolderFromJsonObject} from "./utils.mjs";
|
import {headersTsv, writeFileInOuputFolderFromJsonObject} from "./utils.mjs";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
convertir un json représentant toutes les tâches orgmode en un json rangé par dates
|
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 outputFileNameJson = sourceFileName + '.json';
|
||||||
|
|
||||||
const sourceFilePath = "/home/tykayn/Nextcloud/ressources/social sorting/" + outputFileNameJson
|
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];
|
const events = [headersTsv];
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
let max_count = 10000
|
let max_count = 2000
|
||||||
|
|
||||||
function parseJsonFile() {
|
function parseJsonFile() {
|
||||||
|
|
||||||
fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) {
|
fs.readFile(outputAbsolutePath + outputFileNameJson, 'utf8', function (err, data) {
|
||||||
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
const json_content = JSON.parse(data);
|
const json_content = JSON.parse(data);
|
||||||
console.log(outputAbsolutePath + outputFileNameJson, json_content.tasks_list.length)
|
|
||||||
|
|
||||||
|
|
||||||
// do parse json content and add to tsv lines
|
// do parse json content and add to tsv lines
|
||||||
data.forEach(item => {
|
json_content.tasks_list.forEach(item => {
|
||||||
|
|
||||||
if (counter < max_count) {
|
if (counter < max_count) {
|
||||||
counter++;
|
counter++;
|
||||||
console.log('item', item)
|
|
||||||
|
|
||||||
// TODO ajust lines
|
// TODO ajust lines
|
||||||
let newLine =
|
|
||||||
// item.visit_count + '\t' +
|
let newLine;
|
||||||
// item.title + '\t' +
|
newLine = "" +
|
||||||
// item.description + '\t' +
|
// 0 'amount\t' +
|
||||||
// item.preview_image_url + '\t' +
|
'' + separator_char +
|
||||||
'' + '\t' +
|
// 1 'content\t' +
|
||||||
// 'firefox_place' + '\t' +
|
item.corpus ?? '' + ' ' + separator_char +
|
||||||
'' + '\t' +
|
// 2 'description\t' +
|
||||||
'' + '\t' +
|
item.header + ' '+ separator_char +
|
||||||
// mydate + '\t' +
|
// 3 'destination\t' +
|
||||||
'' + '\t' +
|
'' + separator_char +
|
||||||
'' + '\t'
|
// 4 'end\t' +
|
||||||
url + '\t' +
|
item?.dates?.CLOSED+ ' ' + separator_char +
|
||||||
''
|
// 5 'kind of activity\t' +
|
||||||
// console.log('mydate',stamp, mydate)
|
'' + 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)
|
events.push(newLine)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('events', events.length)
|
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))
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,14 @@ export const headersTsv = 'amount\t' +
|
||||||
'unique id\t' +
|
'unique id\t' +
|
||||||
'url\t'
|
'url\t'
|
||||||
|
|
||||||
|
const outputAbsolutePath = '/home/tykayn/Nextcloud/ressources/social sorting/output/';
|
||||||
|
|
||||||
export async function writeFileInOuputFolderFromJsonObject(fileName, jsonObjectThing) {
|
export async function writeFileInOuputFolderFromJsonObject(fileName, jsonObjectThing) {
|
||||||
|
|
||||||
|
// console.log('statistics.dates', statistics.dates)
|
||||||
|
|
||||||
return await fs.writeFile(
|
return await fs.writeFile(
|
||||||
`${outputAbsolutePath}${fileName}`,
|
`${fileName}`,
|
||||||
JSON.stringify(jsonObjectThing),
|
JSON.stringify(jsonObjectThing),
|
||||||
"utf8",
|
"utf8",
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|
Loading…
Reference in New Issue