使用包含数据换行符的文本字段将CSV导入MySQL Workbench

时间:2017-03-31 18:41:22

标签: php mysql csv upload mysql-workbench

尝试使用解决方案将电子表格中的csv加载到MySQL Workbench中found here

LOAD DATA LOCAL INFILE '/path/to/your/csv/file/model.csv' INTO TABLE test.dummy FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

已加载数据,但电子表格中的某些单元格已包含换行符。在这些情况下,LOAD创造了一个新记录。

Mathematics Kindergarten,Counting,"Say the number sequence 0 to 1000 forward and backward by:
- 5s, 10s or 100s, using any starting point 
- 3s, using starting points that are multiples of 3
- 4s, using starting points that are multiples of 4
- 25s, using starting points that are multiples of 25."

使用此格式的表格:

 Course   |   Topic    | Description

加载的数据如下:

Mathematics Kindergarten   |    Counting    | "Say the number sequence 0 to 1000 forward and backward by:
- 5s, 10s or 100s, using any starting point              |                | 
- 3s, using starting points that are multiples of 3      |                | 
- 4s, using starting points that are multiples of 4      |                | 
- 25s, using starting points that are multiples of 25."  |                | 

如何让系统识别加载数据,以便整个单元格包含完整的描述,并且不会破坏X记录。

1 个答案:

答案 0 :(得分:0)

这些步骤让我回到我导出CSV的文档。我不得不清理数据。

Carriage Returns的单元格中查找并替换Newline\n字符。 还发现了一些其他单元格,其中逗号,为html编号,

这解决了MySQL Workbench数据导入工具的问题。