1

我正在尝试导入具有一些特殊字符的 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," '

我调试文件并\从导致问题的行中删除,然后重新运行上述查询,它运行良好。有没有更好的方法通过查询来做到这一点,或者我每次都必须找到并删除这种字符?

4

1 回答 1

0

似乎不能为 LOAD CSV 配置引号字符(就像 FIELDTERMINATOR 一样):

如果您正在创建一个新数据库,您可以考虑使用 neo4j-import 工具,该工具似乎可以选择配置引号字符(然后只需将其设置为您知道不会出现在 csv 文件中的字符(例如管道符号|):

否则,是的,您将需要在加载之前对输入文件运行清理过程。

于 2016-09-27T18:51:27.613 回答