我正在尝试将一个包含 27797 行的大型 csv 文件导入 MySQL。这是我的代码:
load data local infile 'foo.csv' into table bar fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 lines;
它工作正常。但是,此文件的某些行包含反斜杠 ( \
),例如:
"40395383771234304","40393156566585344","84996340","","","2011-02-23 12:59:44 +0000","引力波宇宙系统广播零号控制站","@woiu了” "403951518304215004","4039227064556392","23063222",""","2011-02-23 12:58:49 +0000","吸引力波波宇宙广播零号站控制,"@wx0真实系统地地"不讲安全电压是\"不讲36V\""而不是\""36V\"",呵呵。"话说要如何测它的电压呢?" "40391869477158912","40390512645124096","23063222","","","2011-02-23 12:45:46 +0000","波这是宇宙广播系统零号站","@wx0的结果,我没有验证过用电脑充电时的感觉是麻麻的感觉。 "15637769883","15637418359","35192555,"","","206-07 15:44:15 +0000","强互不作用力宇宙","@Hc9 那么程序啦,只是个识别程序,就像Android里的ad.exe。$ adb push d:\hc95.tar\gz /tmp/ $ adb pull /system/hc95/eyes d:\re\gz"
导入后,带有反斜杠的行将被破坏。
我该如何解决?我应该使用sed
还是awk
全部替换\
为\
(在 27797 行内......)?或者这可以通过修改 SQL 查询来解决?