JSONコレクションの数が(20〜40まで)異なる500個のフォルダがあります。私はしかし、それはこれが500回行わ必見です検討し、非常に骨の折れると明らかに非常に面倒になりhereとherePython複数のフォルダからJSONコレクションを別々のタブ区切りファイルにエクスポートします。
import os, json
path_to_json = 'C:/Users/SomeFolder'
json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
#list all the files in the folder
print (json_files)
for js in json_files:
with open(os.path.join(path_to_json, js)) as json_file:
#can only print to screen all the json files - need help saving to a tab-delimited file
print (json.load(json_file))
を与えられた答えを以下によりPythonで手動で個別に各フォルダの内容を抽出することができますよ。各JSONフォルダの内容をタブ区切りファイルに繰り返し抽出するためのより高速化された自動化されたアプローチが、大歓迎です。ありがとう
'glob'モジュールを使用して、すべてのファイルに一致する正しい式を見つけます。例えば' */*。json'です。 –
'os.walk()'を使うと、フォルダを再帰的に歩くことができます。 – zwer