Python: Read several json files from a folder

后端 未结 5 792
梦谈多话
梦谈多话 2020-12-04 19:50

I would like to know how to read several json files from a single folder (without specifying the files names, just that they are json files).

Also, it

5条回答
  •  孤街浪徒
    2020-12-04 20:14

    Iterating a (flat) directory is easy with the glob module

    from glob import glob
    
    for f_name in glob('foo/*.json'):
        ...
    

    As for reading JSON directly into pandas, see here.

提交回复
热议问题