【发布时间】:2017-03-15 12:49:21
【问题描述】:
我有一个包含此内容的文本文件
title: A, alert: notice, desc: Starting
title: B, alert: notice, desc: Process Step 1 and 2
Step 1 - Execute
Step 2 - Log
title: C, alert: notice, desc: "Ending"
我想用这种格式将它插入我的 mongo db
{
title: A,
alert: notice,
desc: Starting
},
{
title: B,
alert: notice,
desc: Process Step 1 and 2 Step 1 - Execute Step 2 - Log
},
{
title: C,
alert: notice,
desc: Ending
},
我一直在尝试寻找可以提供帮助的节点包,但几乎所有文件阅读器包都只能读取文件而不允许逐行编辑。 例如,如果下一行是缩进的,它应该与上一行合并。
【问题讨论】:
-
我认为您需要编写一些代码来分析文本数据并根据您的规范将其重组为 json。
-
@VinceBowdrendo 你知道任何可以帮助分析文本文件并允许每行编辑的模块吗?
标签: javascript node.js mongodb npm filereader