Skip to content

Commit ffa3f5a

Browse files
committed
feat(excel) added a script to convert excel to json
1 parent 6689705 commit ffa3f5a

5 files changed

Lines changed: 1079 additions & 487 deletions

File tree

convertExcelToJson.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import XLSX from 'xlsx';
2+
import fs from 'fs';
3+
4+
const convertExcelToJson = () => {
5+
const workbook = XLSX.readFile('./public/tools.xlsx'); // Replace with your Excel file path
6+
const sheetName = workbook.SheetNames[0]; // Assuming first sheet contains the data
7+
const worksheet = workbook.Sheets[sheetName];
8+
9+
// Define the structure of each row
10+
const jsonData = XLSX.utils.sheet_to_json(worksheet, { defval: "" });
11+
12+
const categoriesMap = {};
13+
14+
jsonData.forEach((row) => {
15+
const category = row.category || "Uncategorized";
16+
17+
if (!categoriesMap[category]) {
18+
categoriesMap[category] = { category, tools: [] };
19+
}
20+
21+
const install = {};
22+
23+
// Map the package managers and installation commands dynamically
24+
['choco', 'winget', 'scoop', 'apt', 'dnf', 'pacman', 'homebrew'].forEach(pkg => {
25+
if (row[pkg]) {
26+
install[pkg] = row[pkg];
27+
}
28+
});
29+
30+
categoriesMap[category].tools.push({
31+
name: row.name,
32+
iconsrc: row.iconsrc,
33+
install,
34+
});
35+
});
36+
37+
// Write the JSON data to a file
38+
fs.writeFileSync('tools.json', JSON.stringify(Object.values(categoriesMap), null, 2));
39+
40+
console.log("Excel file has been converted to JSON.");
41+
};
42+
43+
convertExcelToJson();

public/.~lock.tools.xlsx#

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
,shadilrayyan,pop-os,06.07.2025 16:48,file:///home/shadilrayyan/.config/libreoffice/4;

0 commit comments

Comments
 (0)