Import CSV file with null values ​​in phpmyadmin

When I import a csv file into MySQL (phpmyadmin), for all integer values that are not specified in the file, but have a default value of null, an error message appears: #1366 - Incorrect integer value: '' for column 'id' at row 1.. I have the following questions:

and. How to import a csv file that does not have a row identifier if the DB table has this identifier, defined as auto-increment?

b. What do I need in the csv file or in the table column specification in phpmyadmin for an integer column that defaults to null?

Here is an example of lines from a csv file.

id,year,month,date,day,description,ranking
,,3,1,,,
,,3,2,,,
,,3,3,,,
,,3,4,,,
,,3,5,,,
,,3,6,,,
,,3,7,,,
,,3,7,,"Saints Perpetua and Felicity, Martyrs",
,,3,8,,,
,,3,8,,"Saint John of God, Religious",
,,3,9,,,
,,3,9,,"Saint Frances of Rome, Religious",
,,3,10,,,

, , - id, year, ranking. . . INT (11) NULL. .

+2
1

CSV "". , , (, ). , " " NULL

.

$row = fgetcsv(...);
$row[0] = 'NULL';
+1

Source: https://habr.com/ru/post/1785077/


All Articles