-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-formulas.js
More file actions
40 lines (33 loc) · 984 Bytes
/
fix-formulas.js
File metadata and controls
40 lines (33 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fs = require('fs');
const path = require('path');
const files = [
'examples/reactive-system-test.json',
'examples/formula-syntax-comparison.json',
'examples/pricingModel.json'
];
files.forEach(filePath => {
console.log(`Processing ${filePath}...`);
try {
const content = fs.readFileSync(filePath, 'utf8');
const notebook = JSON.parse(content);
// Update formula cells
notebook.cells = notebook.cells.map(cell => {
if (cell.type === 'formula') {
// Keep only required properties
return {
type: cell.type,
id: cell.id,
variableName: cell.variableName,
formula: cell.formula
};
}
return cell;
});
// Write back
fs.writeFileSync(filePath, JSON.stringify(notebook, null, 2));
console.log(`✓ Updated ${filePath}`);
} catch (error) {
console.error(`✗ Error processing ${filePath}:`, error.message);
}
});
console.log('Done!');