-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_multiple_chunks.js
More file actions
44 lines (36 loc) · 1.85 KB
/
Copy pathrun_multiple_chunks.js
File metadata and controls
44 lines (36 loc) · 1.85 KB
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
41
42
43
44
require('dotenv').config();
const path = require('path');
const fs = require('fs');
const { processCsvStream } = require('./src/services/csvService');
const CHUNKS_DIR = `C:\\Users\\nha14\\Desktop\\patient_geo\\chunks\\input-1773997281120-255139062`;
const PROCESSED_DIR = path.join(__dirname, 'processed');
if (!fs.existsSync(PROCESSED_DIR)) fs.mkdirSync(PROCESSED_DIR);
const startChunk = 7;
const endChunk = 12;
async function runChunks() {
for (let i = startChunk; i <= endChunk; i++) {
const inputFileName = `chunk_${i}_input-1773997281120-255139062.csv`;
const inputFilePath = path.join(CHUNKS_DIR, inputFileName);
const outputFilePath = path.join(PROCESSED_DIR, `processed-${inputFileName}`);
if (!fs.existsSync(inputFilePath)) {
console.warn(`[Warning] Chunk ${i} not found at ${inputFilePath}. Skipping...`);
continue;
}
console.log(`\n==================================================`);
console.log(`Starting processing for Chunk ${i}: ${inputFileName}`);
console.log(`Output will be: ${outputFilePath}`);
console.log(`==================================================\n`);
try {
// For chunk 7, start processing from after the given ID.
// For all other chunks, run normally (resume logic still applies via processedIds).
const startAfterId = (i === 7) ? 'SVNSASY/CG/CB/2025/R2/1022189246' : null;
await processCsvStream(inputFilePath, outputFilePath, startAfterId);
console.log(`\n[Success] Completed Chunk ${i}`);
} catch (error) {
console.error(`\n[Error] Failed to process Chunk ${i}:`, error.message);
// Optionally decide if you want to break or continue to next chunk
}
}
console.log('\nAll requested chunks have been processed.');
}
runChunks();