Data cleaning: Difference between revisions
Jump to navigation
Jump to search
→Verify the column values are numeric
| Line 310: | Line 310: | ||
</pre> | </pre> | ||
==== Verify if value is number in MySQL ==== | |||
MySQL: | MySQL: | ||
| Line 325: | Line 326: | ||
* The {{kbd | key=tax_id}} column is 8 digits only. Find the well-formatted {{kbd | key=tax_id}} records by using {{code | code = SELECT * FROM `tax_id` WHERE `tax_id` REGEXP '^[0-9]{8}$'}} | * The {{kbd | key=tax_id}} column is 8 digits only. Find the well-formatted {{kbd | key=tax_id}} records by using {{code | code = SELECT * FROM `tax_id` WHERE `tax_id` REGEXP '^[0-9]{8}$'}} | ||
==== Verify if value is number in PHP ==== | |||
* [http://php.net/manual/en/function.is-numeric.php is_numeric] function | * [http://php.net/manual/en/function.is-numeric.php is_numeric] function | ||
* [https://www.php.net/manual/en/function.is-int.php is_int] function | * [https://www.php.net/manual/en/function.is-int.php is_int] function | ||
==== Verify if value is number in Excel or Google sheet ==== | |||
Excel & [https://www.google.com/sheets/about/ Google Sheets]: | Excel & [https://www.google.com/sheets/about/ Google Sheets]: | ||
* Using [http://www.techonthenet.com/excel/formulas/isnumber.php ISNUMBER Function]: {{code | code = <nowiki>=INT(ISNUMBER(A1))</nowiki>}} | * Using [http://www.techonthenet.com/excel/formulas/isnumber.php ISNUMBER Function]: {{code | code = <nowiki>=INT(ISNUMBER(A1))</nowiki>}} | ||