0
我正在將我的數據從外部文件存儲到localhost中的mongodb。這是相當龐大的數據集,容量爲1.70GB,含有約1000萬條推文。雖然從文件導入到mongodb它顯示我的錯誤「JSON讀者期待一個名字,但發現':'' 我dint以前的文件有任何錯誤。但是,我無法弄清楚。這些數據只是來自JSON格式的流API的tweets實時集合。JSON閱讀器期待一個名字,但發現':'。在Mongodb Java
BufferedReader br = new BufferedReader(new FileReader(file));
int counter = 0;
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
Document old_status = Document.parse(line);
// If it is a deleted tweet, then continue
if (old_status.containsKey("delete")) {
continue;
}
//populate original tweets
Document original_status = new Document();
if(line.contains("retweeted_status")){
Document retweets = (Document)old_status.get("retweeted_status");
original_status.append("status",retweets.get("text"));
original_status.append("Likes",retweets.getInteger("favorite_count"));}}
它的一個示例代碼,用於從文件導入數據到mongo集合。 幫我解決這個問題。我真的停留在這個地方,需要我的時間。 在此先感謝。
看來它不能從你的文件中解析出一行。添加日誌記錄以查看哪條線路導致問題。 –
@ Andriy Simonov- Json格式的錯誤。柯里括號不翼而飛。當json格式不正確時,我想要跳過什麼? – prabhu