9/25/2020

[2020-09] Create Exam Sitting Plan using OCR


# Convert Image to editable list of roll numbers

  1. Scan or Capture a photo from your camera (List of students roll numbers should be in vertical column, so that OCR can easily read them) 
  2. If you want more accurate OCR result then you should crop the image and try to keep just the roll numbers, You can also erase other unwanted things from that photo. 
  3. Open Online OCR website https://ocr.space

# Convert list of roll numbers to HTML tables

1. You should have list of all roll numbers like this 
2021001
2021002
2021004
.
.

2. Open Chrome DevTools and Run this script to create HTML Tables, (You might want to tweak this JS code as per your requirements but this is basic code that I generally use)

This JS code depends upon lodash, so you will need lodash for this code to work

var a = `456539
456543
456548
...
462057
462073
462080
462090
462100
462120
462130`;

var b = a.split("\n");

b = b.map((v,k)=>{
    if ((k + 1) % 4 == 1)
        return 'A   ' + v;
    if ((k + 1) % 4 == 2)
        return 'B   ' + v;
    if ((k + 1) % 4 == 3)
        return 'C   ' + v;
    if ((k + 1) % 4 == 0)
        return 'D   ' + v;
}
);

var c = _(b).chunk(24).map((m)=>_.zip.apply(_, _.chunk(m, 6))).value();

function createTable(i, data) {
    var a = `<p>${i}</p><table border="1"><tbody>`;
    for (var t = 0; t < data.length; t++) {
        a += '<tr>';
        for (var r = 0; r < data[t].length; r++) {
            a += `<td>${data[t][r]}</td>`;
        }
        a += '</tr>';
    }
    a += '</tbody></table>';
    return a;
}

function createTables(tbls) {
    var b = '';
    for (var i = 0; i < tbls.length; i++) {
        b += createTable(i, tbls[i]);
    }
    return b;
}

createTables(c);

3. Copy generated HTML code to Excel


There you have it and now you can paste it into any exam sitting management excel template.


May! You have a nice day.

No comments :