TypeError: a bytes-like object is required, not ‘str’ in python and CSV

You are using Python 2 methodology instead of Python 3. Change: outfile=open(‘./immates.csv’,’wb’) To: outfile=open(‘./immates.csv’,’w’) and you will get a file with the following output: SNo,States,Dist,Population 1,Andhra Pradesh,13,49378776 2,Arunachal Pradesh,16,1382611 3,Assam,27,31169272 4,Bihar,38,103804637 5,Chhattisgarh,19,25540196 6,Goa,2,1457723 7,Gujarat,26,60383628 ….. In Python 3 csv takes the input in text mode, whereas in Python 2 it took it in binary mode. … Read more

HTML table with fixed headers?

This can be cleanly solved in four lines of code. If you only care about modern browsers, a fixed header can be achieved much easier by using CSS transforms. Sounds odd, but works great: HTML and CSS stay as-is. No external JavaScript dependencies. Four lines of code. Works for all configurations (table-layout: fixed, etc.). document.getElementById(“wrap”).addEventListener(“scroll”, … Read more

How can I truncate table cells, but fit as much as content possible?

<table border=”1″ style=”width: 100%;”> <colgroup> <col width=”100%” /> <col width=”0%” /> </colgroup> <tr> <td style=”white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:1px;”>This cell has more content.This cell has more content.This cell has more content.This cell has more content.This cell has more content.This cell has more content.</td> <td style=”white-space: nowrap;”>Less content here.</td> </tr> </table> http://jsfiddle.net/7CURQ/

How to get multiple selected values of select box in php?

If you want PHP to treat $_GET[‘select2’] as an array of options just add square brackets to the name of the select element like this: <select name=”select2[]” multiple … Then you can acces the array in your PHP script <?php header(“Content-Type: text/plain”); foreach ($_GET[‘select2’] as $selectedOption) echo $selectedOption.”\n”; $_GET may be substituted by $_POST depending … Read more

Form inside a table

A form is not allowed to be a child element of a table, tbody or tr. Attempting to put one there will tend to cause the browser to move the form to it appears after the table (while leaving its contents — table rows, table cells, inputs, etc — behind). You can have an entire … Read more

How to deal with page breaks when printing a large HTML table

<!DOCTYPE HTML> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>Test</title> <style type=”text/css”> table { page-break-inside:auto } tr { page-break-inside:avoid; page-break-after:auto } thead { display:table-header-group } tfoot { display:table-footer-group } </style> </head> <body> <table> <thead> <tr><th>heading</th></tr> </thead> <tfoot> <tr><td>notes</td></tr> </tfoot> <tbody> <tr> <td>x</td> </tr> <tr> <td>x</td> </tr> <!– 500 more rows –> <tr> <td>x</td> </tr> </tbody> </table> … Read more

Setting table column width

<table style=”width: 100%”> <colgroup> <col span=”1″ style=”width: 15%;”> <col span=”1″ style=”width: 70%;”> <col span=”1″ style=”width: 15%;”> </colgroup> <!– Put <thead>, <tbody>, and <tr>’s here! –> <tbody> <tr> <td style=”background-color: #777″>15%</td> <td style=”background-color: #aaa”>70%</td> <td style=”background-color: #777″>15%</td> </tr> </tbody> </table>

How to center the contents of an HTML table?

Here is an example with CSS and inline style attributes: td { height: 50px; width: 50px; } #cssTable td { text-align: center; vertical-align: middle; } <table border=”1″> <tr> <td style=”text-align: center; vertical-align: middle;”>Text</td> <td style=”text-align: center; vertical-align: middle;”>Text</td> </tr> </table> <table border=”1″ id=”cssTable”> <tr> <td>Text</td> <td>Text</td> </tr> </table> http://jsfiddle.net/j2h3xo9k/ EDIT: The valign attribute is deprecated … Read more

How do I create an HTML table with a fixed/frozen left column and a scrollable body?

If you want a table where only the columns scroll horizontally, you can position: absolute the first column (and specify its width explicitly), and then wrap the entire table in an overflow-x: scroll block. Don’t bother trying this in IE7, however… Relevant HTML & CSS: table { border-collapse: separate; border-spacing: 0; border-top: 1px solid grey; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)