Skip to content

Instantly share code, notes, and snippets.

@szmeku
Created January 15, 2021 22:24
Show Gist options
  • Save szmeku/1be45f132683cddbb1dcd91e144b2c2c to your computer and use it in GitHub Desktop.
Save szmeku/1be45f132683cddbb1dcd91e144b2c2c to your computer and use it in GitHub Desktop.
madridCoworks.js
let coworks = require('./coworks.json')
const _ = require('ramda')
const fs = require('fs')
let output = '';
_.pipe(
_.map(
_.over(_.lensProp('tarifas'),
_.pipe(
_.filter(_.propEq('period', 'month')), _.map(_.over(_.lensProp('price'), _.pipe(
_.split('€'),
_.head,
_.trim,
_.replace(',', '')
)))
)
)
),
_.forEach(el => {
_.forEach(el2 => {
output += `\n${el.l}, ${el2.name}, ${el2.price}`
}, el.tarifas)
})
)(coworks)
fs.writeFile("./coworks.csv", output, function(err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment