Replies: 6 comments
-
今天看到一个仓库 Flomo To Json。还没测试,不知道导出的json格式是否兼容 |
Beta Was this translation helpful? Give feedback.
-
尝试了一下发现有个小bug:部分memo输出的content会内容重复 例如a b会变成a a b b,需要注意一下 import json, csv, time
from datetime import datetime
def time2ts(x):
return int(datetime.strptime(x, "%Y-%m-%d %H:%M:%S").timestamp())
res = [["id","creator_id","created_ts","updated_ts","row_status","content","visibility"]]
for idx,i in enumerate(json.load(open("myMemos.json"))):
contents = i["content"]
if not contents:
continue
c = [contents[0]]
oldline = contents[0]
for line in contents:
if line==oldline:
continue
oldline = line
c.append(line)
res.append([1005+idx, 101, time2ts(i["time"]), time2ts(i["time"]), "NORMAL", "\n".join(c)+" ", "PRIVATE"])
csv.writer(open("out.csv", "w")).writerows(res) 我写了这个简单的python来转换为csv格式,然后用navicat手动导入了一下(从服务器复制db文件 navicat打开 对memo表导入 db文件复制到服务器替换) 效果还行 |
Beta Was this translation helpful? Give feedback.
-
因为涉及到编码问题,我在这位作者的源代码基础上添加上了UTF-8编码参数,经测试使用没有问题 import json, csv, time
from datetime import datetime
def time2ts(x):
return int(datetime.strptime(x, "%Y-%m-%d %H:%M:%S").timestamp())
res = [["id","creator_id","created_ts","updated_ts","row_status","content","visibility"]]
for idx,i in enumerate(json.load(open("myMemos.json",encoding="UTF-8"))):
contents = i["content"]
if not contents:
continue
c = [contents[0]]
oldline = contents[0]
for line in contents:
if line==oldline:
continue
oldline = line
c.append(line)
res.append([1005+idx, 101, time2ts(i["time"]), time2ts(i["time"]), "NORMAL", "\n".join(c)+" ", "PRIVATE"])
csv.writer(open("out.csv", "w",encoding="UTF-8")).writerows(res) |
Beta Was this translation helpful? Give feedback.
-
有官方开发的导入功能吗? |
Beta Was this translation helpful? Give feedback.
-
参照 flomoParse 搞了一个Python版本的 flomo2memos ,可以直接通过API导入,不用额外操作数据库。 |
Beta Was this translation helpful? Give feedback.
-
https://github.com/JakeLaoyu/memos-import-from-flomo 支持 flomo 的数据导入到 Memos。 |
Beta Was this translation helpful? Give feedback.
-
https://help.flomoapp.com/basic/storage.html
flomo导出的数据是html格式的,如何导入到memos?
Beta Was this translation helpful? Give feedback.
All reactions