-
-
Save brianpooe/abc303467f2f98bb2de47ab09dd4ff87 to your computer and use it in GitHub Desktop.
This file contains 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
const xlsx = require('xlsx'); | |
const filePath = process.argv.slice(2)[0]; | |
const workbook = xlsx.readFile(filePath); | |
const worksheet = workbook.Sheets[workbook.SheetNames[0]]; | |
let posts = []; | |
let post = {}; | |
for (let cell in worksheet) { | |
const cellAsString = cell.toString(); | |
if (cellAsString[1] !== 'r' && cellAsString[1] !== 'm' && cellAsString[1] > 1) { | |
if (cellAsString[0] === 'A') { | |
post.title = worksheet[cell].v; | |
} | |
if (cellAsString[0] === 'B') { | |
post.author = worksheet[cell].v; | |
} | |
if (cellAsString[0] === 'C') { | |
post.released = worksheet[cell].v; | |
posts.push(post); | |
post = {}; | |
} | |
} | |
} | |
console.log(posts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment