如何在3 GB文本文件的行末添加逗号?

时间:2019-07-19 14:12:36

标签: json text dataset notepad++

我有一个名为.json扩展名的3GB数据集。我想在每行的末尾添加逗号(最后一行除外),以验证JSON文件并导入excel。 Notepad ++不支持大文件。

我尝试以编程方式添加逗号,在小文件上效果很好,但在大文件上效果不佳。我还尝试了010 Editor,UltraEdit,Sublime Text,但没有任何帮助。 需要替换此:

{
  "tweet_id": "3600118565656676",  
  "tweet_city": "mansfield-engj9-gb", 
  "tweet_latitude": "53.130483", 
  "tweet_longitude": "-1.141419"
}

使用:

{  
  "tweet_id": "3600118565656676", 
  "tweet_city": "mansfield-engj9-gb", 
  "tweet_latitude": "53.130483", 
  "tweet_longitude": "-1.141419"
},

1 个答案:

答案 0 :(得分:0)

使用记事本++:

  • Ctrl + H
  • 查找内容:(?<=})(?!\s*,)
  • 替换为:,
  • 检查环绕
  • 检查正则表达式
  • 全部替换

说明:

(?<=        # positive lookbehind, make sure we have before:
  }         # closing curly brace
)           # end lookbehind
(?!         # negative lookahead, make sure we haven't after:
  \s*,      # 0 or more space and a comma
)           # end lookbehind
相关问题