Created At: 2026-06-14T13:53:02Z
Completed At: 2026-06-14T13:53:02Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 4581
Total Bytes: 193572
Showing lines 4200 to 4280
The following code has been modified to include a line number before every line, in the format: <line_number>: <original_line>. Please note that any changes targeting the original code should remove the line number, colon, and leading space.
4200:       let separator = ',';
4201:       const firstLine = lines[0];
4202:       const commas = (firstLine.match(/,/g) || []).length;
4203:       const semicolons = (firstLine.match(/;/g) || []).length;
4204:       if (semicolons > commas) {
4205:         separator = ';';
4206:       }
4207:       
4208:       const headers1 = firstLine.split(separator).map(h => h.trim().replace(/^["']|["']$/g, ''));
4209:       const headers2 = lines[1] ? lines[1].split(separator).map(h => h.trim().replace(/^["']|["']$/g, '')) : [];
4210:       
4211:       // Check if it is a two-row header format (as shown in the user's image)
4212:       let isTwoRowHeader = false;
4213:       if (headers2.length > 0) {
4214:         const h2Lower = headers2.map(h => h.toLowerCase());
4215:         const hasMin = h2Lower.some(h => h.includes('min') || h.includes('bawah'));
4216:         const hasMax = h2Lower.some(h => h.includes('max') || h.includes('atas'));
4217:         const hasMedian = h2Lower.some(h => h.includes('median') || h.includes('mean'));
4218:         const hasSsp = headers1.some(h => h.toLowerCase().includes('ssp'));
4219:         if ((hasMin || hasMax || hasMedian) && hasSsp) {
4220:           isTwoRowHeader = true;
4221:         }
4222:       }
4223: 
4224:       if (isTwoRowHeader) {
4225:         const colMap = {};
4226:         let currentSSP = '';
4227:         const colCount = Math.max(headers1.length, headers2.length);
4228:         for (let col = 0; col < colCount; col++) {
4229:           const h1 = (headers1[col] || '').trim();
4230:           const h2 = (header
<truncated 936 bytes>
hun') || h2Lower === 'y' || h2Lower === 'yr') {
4246:             colMap[col] = 'year';
4247:           } else if (h1Lower.includes('hist') || h1Lower.includes('obs') || h1Lower.includes('real') ||
4248:                      h2Lower.includes('hist') || h2Lower.includes('obs') || h2Lower.includes('real')) {
4249:             colMap[col] = 'historical';
4250:           } else if (currentSSP) {
4251:             if (h2Lower.includes('min') || h2Lower.includes('bawah')) {
4252:               colMap[col] = currentSSP + '_min';
4253:             } else if (h2Lower.includes('max') || h2Lower.includes('atas')) {
4254:               colMap[col] = currentSSP + '_max';
4255:             } else if (h2Lower.includes('median') || h2Lower.includes('mean') || h2Lower === '') {
4256:               colMap[col] = currentSSP;
4257:             }
4258:           }
4259:         }
4260: 
4261:         const yearColIndex = Object.keys(colMap).find(idx => colMap[idx] === 'year');
4262:         const parsedRows = [];
4263:         for (let i = 2; i < lines.length; i++) {
4264:           const cols = lines[i].split(separator).map(c => c.trim().replace(/^["']|["']$/g, ''));
4265:           const yearVal = yearColIndex !== undefined ? parseInt(cols[yearColIndex]) : parseInt(cols[0]);
4266:           if (isNaN(yearVal)) continue;
4267: 
4268:           const row = { year: yearVal };
4269:           for (let col = 0; col < cols.length; col++) {
4270:             const key = colMap[col];
4271:             if (key) {
4272:               const valStr = cols[col];
4273:               if (valStr !== undefined && valStr !== '') {
4274:                 const val = parseFloat(valStr);
4275:                 row[key] = isNaN(val) ? null : val;
4276:               } else {
4277:                 row[key] = null;
4278:               }
4279:             }
4280:           }
The above content does NOT show the entire file contents. If you need to view any lines of the file which were not shown to complete your task, call this tool again to view those lines.
