Last active
May 28, 2022 15:17
-
-
Save davidcsejtei/21a1d689ba86a6f5093974631f5a3986 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); |
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]]; | |
const data = xlsx.utils.sheet_to_json(worksheet, { | |
header: "A", | |
range: 9 | |
}); | |
data.map(aa => { | |
console.log(aa); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment