MySQL issue when importing specific CSV files with blank values in random rows -
i had brought before earlier, after doing research, realized looking in wrong place. here situation. create table:
create table pc_contacts ( poc varchar(255) primary key not null, phone_1 varchar(255), phone_2 varchar(255) );
i import csv file mysql has values table pc_contacts:
use network load data infile 'c:\\programdata\\mysql\\mysql server 5.7\\uploads\\pc_contacts.csv' table pc_contacts fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 rows;
my output after importing looks this:
+------------------+--------------+---------------+ | poc | phone_1 | phone_2 | +------------------+--------------+---------------+ |april wilson | 123-456-5000 | 123-456-5006 | | 123-456-2222 | | | 123-456-5331 | | | 123-456-7772 | |anton watson | 123-456-1258 | 123-456-6005 |elisa kerring | 123-456-1075 | 123-456-4475
now may recall, based on code input, poc pk. had, in original csv file, value every line. however, see, has no value on right affects left column's values. however, if looked in gui , pulled table there, showed cell populated value, data there. if put in xxx-xxx-xxxx, fix issue:
+------------------+--------------+---------------+ | poc | phone_1 | phone_2 | +------------------+--------------+---------------+ |april wilson | 123-456-5000 | 123-456-5006 |nicky nite | 123-456-2222 | xxx-xxx-xxxx |nicole | 123-456-5331 | xxx-xxx-xxxx |becky | 123-456-7772 | xxx-xxx-xxxx |anton watson | 123-456-1258 | 123-456-6005 |elisa kerring | 123-456-1075 | 123-456-4475
obviously intentions can see value without having apply special formatting in command line. there special select command maybe?
here link portion of .csv, requested:
https://drive.google.com/file/d/0b0mmqhn75rpgdkzhcgp0swtmams/view?usp=sharing
your csv file contains carriage return newline @ end of row, breaks formatting. use:
select poc, phone_1, replace(phone_2, '\r', '') phone_2 pc_contacts;
or change import query follows:
use network load data infile 'c:\\programdata\\mysql\\mysql server 5.7\\uploads\\pc_contacts.csv' table pc_contacts fields terminated ',' enclosed '"' lines terminated '\r\n' ignore 1 rows;
and use simple select
:
select * pc_contacts;
Comments
Post a Comment