Skip to content

Instantly share code, notes, and snippets.

@Wolfr
Created February 1, 2014 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wolfr/8752392 to your computer and use it in GitHub Desktop.
Save Wolfr/8752392 to your computer and use it in GitHub Desktop.
timekeeper.js
// Node timekeeper
// Used to parse output from iCal to CSV (tab delimited) that can be imported in numbers
// You need to put the contents in a file called test.txt in the same folder as timekeeper.js
var fs = require('fs')
fs.readFile('test.txt', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var result = string.match(regex);
// Need to find a way to do a loop instead of a single replace
var result =
data
.replace(/Location: \n/, '');
fs.writeFile('test.txt', result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
// Regexes uit te voeren:
// How to loop this?
// Replace Location: \n by [nothing]
// Replace Scheduled: by [nothing]
// Replace ical(.*) by [nothing]
// Replace \n\n\n by \n\n\n
// Replace " Jan " by -01-
// Replace [0-9]{2}-[0-9]{2}-[0-9]{4} by $0\n
// Replace "\[(.*)\] " by $0\n
// Replace $^ by LINEMARKER
// Replace \n by \t
// Replace LINEMARKER by \n
// Replace ^\t{1} by ""
// Replace \[ by ""
// Replace \] by ""
// Replace ^b by ""
// Replace ^([0-9|,]{1,})([h]) by $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment