你好我试图在另一个python脚本中运行一个python脚本,我试图用os.system()来做。问题是这个脚本是一个json到csv转换器,它有2个参数(它们是json文件输入的目录,输出csv文件的目录)然后它有--include和 - -ignore与我们想要在csv文件中传输的json数据有关。所以基本上当我在终端上运行它(它在那里工作)时,它看起来像这样:
python file/tmp/python/json_to_csv.py -i results/2.json -o results/csv_folder/2.csv --include metadata.audio_properties.* metadata.tags.musicbrainz_recordingid.0 lowlevel.* rhythm.* tonal.* --ignore *.min *.min.* *.max *.max.* *.dvar *.dvar2 *.dvar.* *.dvar2.* *.dmean *.dmean2 *.dmean.* *.dmean2.* *.cov.* *.icov.* rhythm.beats_position.* --add-filename
在ipython里面,我试过这样的事情:
os.system(“essentia/src/examples/python/json_to_csv.py -i results/24.mp3.json -o results/csv_folder/24.csv --include metadata.audio_properties.* metadata.tags.musicbrainz_recordingid.0 lowlevel.* rhythm.* tonal.* --ignore *.min *.min.* *.max *.max.* *.dvar *.dvar2 *.dvar.* *.dvar2.* *.dmean *.dmean2 *.dmean.* *.dmean2.* *.cov.* *.icov.* rhythm.beats_position.* --add-filename”)
或者这个:
os.system(CONVERTOR + ' "' + jsons + '" "' + csvs + '"')
但没有任何效果。有谁知道这怎么可行? 提前致谢
答案 0 :(得分:0)
毕竟正确的是:
subprocess.call(["json_to_csv.py", "-i", "json_file", "-o", "csv_file", "--include", "metadata.audio_properties.* metadata.tags.musicbrainz_recordingid.0 lowlevel.* rhythm.* tonal.*", "--ignore", "*.min *.min.* *.max *.max.* *.dvar *.dvar2 *.dvar.* *.dvar2.* *.dmean *.dmean2 *.dmean.* *.dmean2.* *.cov.* *.icov.* rhythm.beats_position.*", "--add-filename"])