2016-09-27 930 views
0

我試圖導入其中有一些特殊的字符,如' , " , \ CSV文件CSV當我運行此查詢 -的Neo4j - 如何導入具有特殊字符

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

它不會出現引號字符可配置爲LOAD CSV(如FIELDTERMINATOR是):

如果您要創建一個新的數據庫,你可以看看改成使用neo4j-import工具,它似乎可以選擇配置引號字符(然後將其設置爲您知道的字符不會存在於您的csv文件中(例如說是管道符號|):

否則,是的,你將需要在裝載前,輸入文件運行一個清洗的過程。

+0

有沒有其他可行的方法來做到這一點?直接從文件中刪除可能會很麻煩。 –