我正在尝试导入csv文件,当我运行此查询时,该文件包含一些特殊字符,例如' , " , \
-
LOAD CSV WITH HEADERS FROM "http://192.168.11.121/movie-reco-db/movie_node.csv" as row
CREATE (:Movie_new {movieId: row.movie_id, title: row.title, runtime: row.runtime, metaScore: row.meta_score, imdbRating: row.IMDB_rating, imdbVotes: row.IMDB_votes , released: row.released , description: row.description , watchCount: row.watch_count , country: row.country ,
category: row.category , award: row.award , plot: row.plot , timestamp: row.timestamp})
它会抛出错误 -
At http://192.168.11.121/movie-reco-db/movie_node.csv:35 - there's a field starting with a quote and whereas it ends that quote there seems to be characters in that field after that ending quote. That isn't supported. This is what I read: ' Awesome skills performed by skillful players! Football Circus! If you like my work, become a fan on facebook",0,USA,Football,N/A,N/A,1466776986
260,T.J. Miller: No Real Reason,0,0,7.4,70,2011-11-15," '
我调试文件并从导致问题的行中删除\
,然后重新运行上面的查询,它运行良好。有什么更好的方法可以通过查询来完成它,或者每次我必须找到并删除这种类型的字符?
答案 0 :(得分:0)
引号字符不能配置为LOAD CSV(就像FIELDTERMINATOR一样):
如果你正在创建一个新的数据库,你可以考虑使用neo4j-import工具,该工具似乎可以选择配置引用字符(然后只需将其设置为你知道赢得的字符&#39 ; t在您的csv文件中(例如管道符号|):
否则,是的,您需要在加载前对输入文件运行清理过程。