python - 如何在 Linux 上递归提取数据?

标签 python linux mongodb unicode utf-8

我正在尝试处理大型数据集,但是,数据的格式结构已拆分为数百个目录。

data/: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z

data/0: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/1: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/2: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/3: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/4: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/5: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/6: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/7: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/8: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/9: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

data/a: 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s symbols t u v w x y z

此外,文件类型也是完全随机的。

0: UTF-8 Unicode text

1: UTF-8 Unicode text

2: UTF-8 Unicode text

3: UTF-8 Unicode text

4: UTF-8 Unicode text

5: Non-ISO extended-ASCII text, with LF, NEL line terminators

6: UTF-8 Unicode text

7: UTF-8 Unicode text

8: UTF-8 Unicode text

9: UTF-8 Unicode text

a: UTF-8 Unicode text

...

z: UTF-8 Unicode text

文件包含 email:password 格式。

如何将所有内容放入 JSON 文件或 CSV 文件中?

我正在寻找将数据导入 MongoDB 的方法。

谢谢。

最佳答案

我相信有人会比我更好地帮助你,但如果我能为你指明正确的方向,我会的。

您尝试过编写 perl 脚本吗?即

    opendir(DIR, ".");
 @files = grep(/\.cnf$/,readdir(DIR));
 closedir(DIR);

 foreach $file (@files) {
    //shuv in a JSON file
}

类似的东西?

关于python - 如何在 Linux 上递归提取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48095268/

相关文章:

python - 如何使用python绘制彩色扇区?

javascript - mongodb 搜索查询 - 返回所有结果(也包括不匹配的结果)

python - 在 peewee.Model 对象上覆盖 __hash__ 是否安全?

python - pywinauto:如何选择这个对话框?使用哪种 spy 工具?我需要什么信息?

linux - 我在Linux中安装了kibana,但无法正常工作

linux - 强制丢包

mongodb - 没有像 mongodb 那样简单的 AWS DocumentDB 可视化?

python - 我应该如何附加到 mongodb 中的小文件状对象?

python - Django - 在不访问数据库的情况下访问外键值

linux - 如何在 Linux x86_64 系统上获取 VDSO 的大小