Created
January 15, 2021 22:24
-
-
Save szmeku/1be45f132683cddbb1dcd91e144b2c2c to your computer and use it in GitHub Desktop.
madridCoworks.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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