Skip to main content

Microsoft CoPilot AI Code Assistant Sample Project: Web App for Table Similarity Comparison

PROMPT

1st PROMPT:

create application program (web-based code) two compare similarity between 2 uploaded table (1 colomn multiple row)


2nd PROMPT:

add export function to the web-page (3 row: unique in table1, similar number, and unique in table2)


3rd PROMPT:

the report in web-page or export file should be in 3 colomn: 1) unique in table 1 2) similar values 3) unique in table 2


4th PROMPT:

add one colomn in left as row number and each row is categorized among those 3 colomn: 1) unique in table 1 2) similar values 3) unique in table 2


Responsive image




TABLE 1 & TABLE 2

table1

| Number |

| ------ |

| 1723   |

| 5042   |

| 8125   |

| 9348   |

| 2301   |

| 9120   |

| 6634   |

| 3588   |

| 7791   |

| 1290   |

| 8734   |

| 5010   |

| 3911   |

| 7133   |

| 6024   |

| 9388   |

| 6789   |

| 2507   |

| 4876   |

| 3344   |


table2

| Number |

| ------ |

| 8125   |

| 5042   |

| 3344   |

| 7081   |

| 1166   |

| 8023   |

| 1723   |

| 2790   |

| 6789   |

| 9120   |

| 9999   |

| 6024   |

| 2444   |

| 1001   |

| 7133   |

| 3210   |

| 7388   |

| 3588   |

| 1357   |

| 1890   |




CODE

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Table Similarity Checker</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body class="bg-light p-4"> <div class="container"> <h2 class="mb-4">🔍 Compare Table Similarity</h2> <div class="mb-3"> <label for="file1" class="form-label" >Upload Table 1 (CSV)</label > <input type="file" id="file1" accept=".csv" class="form-control" /> </div> <div class="mb-3"> <label for="file2" class="form-label" >Upload Table 2 (CSV)</label > <input type="file" id="file2" accept=".csv" class="form-control" /> </div> <button class="btn btn-primary me-2" onclick="compareTables()" > Compare </button> <button class="btn btn-success" id="exportBtn" onclick="exportCSV()" disabled > Export Results </button> <div id="result" class="mt-4"></div> </div> <script> let categorizedRows = []; function readCSV(file, callback) { const reader = new FileReader(); reader.onload = function (e) { const lines = e.target.result .split(/\r?\n/) .map((line) => line.trim() ) .filter( (line) => line ); callback(lines); }; reader.readAsText(file); } function compareTables() { const file1 = document.getElementById( "file1" ).files[0]; const file2 = document.getElementById( "file2" ).files[0]; if (!file1 || !file2) { alert( "Please upload both files." ); return; } readCSV(file1, (data1) => { readCSV(file2, (data2) => { const set1 = new Set( data1 ); const set2 = new Set( data2 ); const common = [ ...set1, ].filter((item) => set2.has( item ) ); const unique1 = [ ...set1, ].filter( (item) => !set2.has( item ) ); const unique2 = [ ...set2, ].filter( (item) => !set1.has( item ) ); const total = new Set([ ...data1, ...data2, ]).size; const similarity = ( (common.length / total) * 100 ).toFixed(2); // Build categorized rows categorizedRows = []; unique1.forEach( (val) => categorizedRows.push( [ val, "", "", ] ) ); common.forEach( (val) => categorizedRows.push( [ "", val, "", ] ) ); unique2.forEach( (val) => categorizedRows.push( [ "", "", val, ] ) ); // Build HTML table let tableHTML = ` <h4>✅ Similarity: ${similarity}%</h4> <table class="table table-bordered"> <thead class="table-light"> <tr> <th>Row</th> <th>Unique in Table 1</th> <th>Similar Values</th> <th>Unique in Table 2</th> </tr> </thead> <tbody> `; categorizedRows.forEach( ( row, index ) => { tableHTML += ` <tr> <td>${index + 1}</td> <td>${row[0]}</td> <td>${row[1]}</td> <td>${row[2]}</td> </tr> `; } ); tableHTML += "</tbody></table>"; document.getElementById( "result" ).innerHTML = tableHTML; document.getElementById( "exportBtn" ).disabled = false; }); }); } function exportCSV() { const rows = [ [ "Row", "Unique in Table 1", "Similar Values", "Unique in Table 2", ], ]; categorizedRows.forEach( (row, index) => { rows.push([ index + 1, ...row, ]); } ); const csvContent = rows .map((row) => row.join(",")) .join("\n"); const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;", }); const url = URL.createObjectURL(blob); const link = document.createElement("a"); link.setAttribute("href", url); link.setAttribute( "download", "table_similarity_results.csv" ); document.body.appendChild(link); link.click(); document.body.removeChild(link); } </script> </body> </html>




WEB APP

Responsive image


RESULT
Row Unique in Table 1     Similar Values     Unique in Table 2
1         9348
2         2301
3         6634
4         7791
5         1290
6         8734
7         5010
8         3911
9         9388
10         2507
11         4876
12                     1723
13                     5042
14                     8125
15                     9120
16                     3588
17                     7133
18                     6024
19                     6789
20                     3344
21                             7081
22                             1166
23                             8023
24                             2790
25                             9999
26                             2444
27                             1001
28                             3210
29                             7388
30                             1357
31                             1890

Comments

Popular posts from this blog

Utk yg mo Bantu2 Keuangan saya
..monggo ke Bank Central Asia BCA 5520166779 a.n. Andreas Tparlaungan Manurung (Indonesia)


For those who would like to help support my finances
..please feel free to send it to Bank Central Asia (BCA) account number 5520166779 under the name Andreas Tparlaungan Manurung (Indonesia)

ANDREAS TOMMY PARLAUNGAN MANURUNG SHARED POOLING ACCOUNT MY ANDROID APKs PAGE please download here! REFRESH PAGE aka CHECK LATEST UPDATE! DOWNLOAD "SHOWING" POOL OF MY ANDROID-APK(s) aka APK CONTAINING LIST OF ALL MY ANDROID-APK(s) APP CLICK HERE FOR ALWAYS BEING UPDATED FOR MY LATEST APK! CONTOH HASIL "PROGRAM" App: Prompts' Guide aka TEMPLATE-HELPERs click here to download! Youtube and Instagram EMBEDded to Blogger/Blogspot.com SOURCE CODE Click this box to download 📥 TikTok EMBEDded to Blogger/Blogspot.com SOURCE CODE Input: BrowserLINK (mandatory) Click this box to download SHORTCUT-APPs note :  "precise" click to download R8: ronin1985.blogspot.com R2M: ronin-manu.blogspot.com Helping Download(ing) OnlineVIDEO! ...

Donation Account + CustomAPPs

Utk yg mo Bantu2 Keuangan saya ..monggo ke Bank Central Asia BCA 5520166779 a.n. Andreas Tparlaungan Manurung (Indonesia) For those who would like to help support my finances ..please feel free to send it to Bank Central Asia (BCA) account number 5520166779 under the name Andreas Tparlaungan Manurung (Indonesia). Web-Based to Android Apps Convertion (MEDIAN.CO etc.) CONTOH HASIL Android APK "PROGRAM" SAMPLE: Youtube and Instagram EMBEDded to Blogger/Blogspot.com SOURCE CODE Click this box to download Contoh Sample SHORTCUT-APPs "precise" click to download : median.co R8: ronin1985.blogspot.com R2M: ronin-manu.blogspot.com Gw udah coba Median.co utk mengubah Website gw menjadi Aplikasi Android Keren bet!! Median.co Cekidot Software lain yg mirip! ChatGPT : If you're looking for tools similar to Median.co to convert websites into Android apps, here are some...

REPOST: Studying WATER PUMP by ROMAN ENGINEERING

*^ Ini yg Asli Gan! Mekanisme pada Concrete Pump: Kok ky Sistem Mekanik Romawi ya?! Tapi malah bisa HANYA pake PER aka bukan "MATA BOR look a like" Mekanisme Drill yg Cost Pembuatan bikin REPOT aka harus Tool SUPER Khusus Dari Material Besi yg digunakan terlihat langsung secara kasat mata Jauh Lebih Banyak drpd Per Biasa seperti yg ditunjukkan pd Video Alternatif dgn Penggunaan PER Video dr Instagram: Source: YouTube Rome's drainage machines #history #romanempire #engineering