关于将文本数据导入phpmyadmin的mysql或php帮助

时间:2015-08-14 21:45:14

标签: php mysql

我有这种格式的文字

132B1A0101 RT22011 BUILDING PLANNING & DRAWING 16 25 3
132B1A0101 RT22012 HYDRAULICS AND HYDRAULIC MACHINERY 17 24 3
132B1A0101 RT22013 STRENGTH OF MATERIALS- II 16 30 3
132B1A0101 RT22014 MANAGERIAL ECONOMICS AND FINANCIAL ANALYSIS 22 24 3
132B1A0101 RT22015 CONCRETE TECHNOLOGY 20 37 3
132B1A0101 RT22016 STRUCTURAL ANALYSIS - I 14 18 0
132B1A0101 RT22017 FLUID MECHANICS & HYDRAULIC MACHINERY LAB 19 38 2

我正在使用此代码将该数据导入mysql bur它对我没有帮助

LOAD DATA LOCAL INFILE '/tmp/foo.txt' 
INTO TABLE foo COLUMNS TERMINATED BY '\t';

请帮我用mysql或php编码加载这些数据

1 个答案:

答案 0 :(得分:0)

尝试将foo.txt编辑为

132B1A0101,RT22011,"BUILDING PLANNING & DRAWING",16,25,3
132B1A0101,RT22012,"HYDRAULICS AND HYDRAULIC MACHINERY",17,24,3
132B1A0101,RT22013,"STRENGTH OF MATERIALS- II",16,30,3
132B1A0101,RT22014,"MANAGERIAL ECONOMICS AND FINANCIAL ANALYSIS",22,24,3
132B1A0101,RT22015,"CONCRETE TECHNOLOGY",20,37,3
132B1A0101,RT22016,"STRUCTURAL ANALYSIS - I",14,18,0
132B1A0101,RT22017,"FLUID MECHANICS & HYDRAULIC MACHINERY LAB",19,38,2

然后再次尝试加载。