2015-05-12 79 views
0

我有一列有4000個字符以上的值,當我做導入時,該值被截斷,我失去了大量的字符串。Mysql導入縮短csv字符串值

mysqlimport --ignore-lines=1 --fields-terminated-by=, --local -u root -p bustracker routes.dat 

這裏是表模式:

CREATE TABLE `routes` (
    `id_rota` varchar(255) NOT NULL, 
    `nome` varchar(255) DEFAULT NULL, 
    `descricao` varchar(255) DEFAULT NULL, 
    `painel` varchar(255) DEFAULT NULL, 
    `PONTOS` varchar(255) DEFAULT NULL, 
    `via` longtext, 
    PRIMARY KEY (`id_rota`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 

和值從列一個樣本:

"-22.379037627611112;-41.78099513053894|-22.37803562340893;-41.779890060424805|-22.37779256189631;-41.77871525287628|-22.37763878806703;-41.77806615829468|-22.377480053613432;-41.77732586860657|-22.377385804945934;-41.77704155445099|-22.376200250466766;-41.77593648433685|-22.375525620815263;-41.775373220443726|-22.375138699392504;-41.77518010139465|-22.374736895238072;-41.77599549293518|-22.3742755631118;-41.77645146846771|-22.372936203113823;-41.77703082561493|-22.372182187371042;-41.777368783950806|-22.37121;-41.77750000000003|-22.370495558423897;-41.77723467350006|-22.370049094399714;-41.77659094333649|-22.369706804344865;-41.77608668804169|-22.369463728287645;-41.77577018737793|-22.36774730160062;-41.77517473697662|-22.367027983546734;-41.77492797374725|-22.366556704186155;-41.77479922771454|-22.36575800604854;-41.77469193935394|-22.36528672238961;-41.77457392215729|-22.36457235253901;-41.77434325218201|-22.363089031214073;-41.77359223365784|-22.36243418199003;-41.77322745323181|-22.36182397880531;-41.77296459674835|-22.36105005872538;-41.77272856235504|-22.359740338024146;-41.77233695983887|-22.35897136748051;-41.772106289863586|-22.35845044953904;-41.771918535232544|-22.357865034670528;-41.77170932292938|-22.357368918449243;-41.77145719528198|-22.35690256759022;-41.77108705043793|-22.35619807716181;-41.77049160003662|-22.355488621932906;-41.76996052265167|-22.35403001032276;-41.768866181373596|-22.35324612430546;-41.76818490028381|-22.3525068859828;-41.76733195781708|-22.352174475525867;-41.766902804374695|-22.351956175689917;-41.76653802394867|-22.3513756949169;-41.76544368267059|-22.350179996131526;-41.76309943199158|-22.34966896821001;-41.762128472328186|-22.348815597017953;-41.76033675670624|-22.348493100730195;-41.759655475616455|-22.348230141666313;-41.7590868473053|-22.348160680698672;-41.758657693862915|-22.347991989633144;-41.75826609134674|-22.347580184115525;-41.75780475139618|-22.34741;-41.75755000000004|-22.3472;-41.757119999999986|-22.346905415817804;-41.75651729106903|-22.34648368397281;-41.75570726394653|-22.345937911455625;-41.754634380340576|-22.345134133493687;-41.753089427948|-22.344320427625874;-41.75156593322754|-22.34364564354736;-41.75023555755615|-22.343005587983747;-41.74903929233551|-22.342057903419103;-41.74754798412323|-22.341611348249877;-41.74684524536133|-22.34118463864063;-41.746206879615784|-22.33564;-41.73782|-22.334942620899053;-41.73679769039154|-22.33469948418864;-41.73649191856384|-22.33364754088381;-41.735199093818664|-22.33293797087169;-41.734410524368286|-22.332248245511906;-41.73356831073761|-22.33176196227294;-41.73303723335266|-22.33102757212712;-41.73233449459076|-22.326129884920256;-41.72701835632324|-22.325152311773006;-41.72611713409424|-22.324795024446622;-41.72582745552063|-22.323782705386893;-41.72515690326691|-22.32270586773761;-41.724486351013184|-22.321549622669163;-41.723912358284|-22.320338780654538;-41.7233008146286|-22.319028677462025;-41.7225980758667|-22.31803120428546;-41.72204554080963|-22.31648783621854;-41.721208691596985|-22.315604486045057;-41.720736622810364|-22.315008965919666;-41.7205274105072|-22.314651652624992;-41.72010362148285|-22.31403;-41.71996999999999|-22.31317276287386;-41.71925604343414|-22.314185158891614;-41.719685196876526|-22.31420997242733;-41.72040939331055|-22.31387747068241;-41.720441579818726|-22.31346060170427;-41.72053277492523|-22.312701301438526;-41.720935106277466|-22.311678969067472;-41.72150373458862|-22.311023878370246;-41.72188460826874|-22.309147919825417;-41.722952127456665|-22.306775639865652;-41.72435760498047|-22.30624460096543;-41.724658|-22.30570363402825;-41.72485649585724|-22.305256962500774;-41.72489404678345|-22.30464154605627;-41.72488868236542|-22.30432887375935;-41.72487258911133|-22.304036053037038;-41.72478675842285|-22.30349011445793;-41.72460436820984|-22.30309802998002;-41.72432541847229|-22.301400638911975;-41.722480058670044|-22.300442745374862;-41.72206163406372|-22.30018465894629;-41.7224907875" 

任何人都知道我通過續集專業,並通過與終端沒有進口如何導入.csv而不丟失數據?

+0

什麼是你的coumn的長度? –

+0

列類型是longtext –

回答

0

確保添加了--fields-optionally-enclosed-by='\"'--lines-terminated-by='\n'以確保您捕獲完整的數據集。

此外,添加--verbose來診斷潛在問題,並--replace以確保您獲取最新的導入數據。

完整的導入應該閱讀;

mysqlimport        \ 
--verbose        \ 
--replace        \ 
--ignore-lines=1      \ 
--fields-terminated-by=','    \ 
--fields-optionally-enclosed-by='\"' \ 
--lines-terminated-by='\n'    \ 
--local        \ 
-u root -p bustracker     \ 
routes.dat 
+0

我最終把類型的不同列,thnks --verbose建議。 –