【问题标题】:Execute a python script from terminal that reads an input file from a folder and writes an output file in another folder从终端执行 python 脚本,从文件夹中读取输入文件并将输出文件写入另一个文件夹
【发布时间】:2023-03-18 08:39:01
【问题描述】:

我正在尝试编写一个 bash 脚本,该脚本从一个文件夹读取和输入 .csv 文件,执行一个 python 文件并将输出文件写入另一个文件夹中的 .csv 文件。这样您就可以在终端上输入如下内容:

输入文件夹\输入文件.csv | python script.py > outputFolder\output_file.csv.

我该怎么做?

感谢您的帮助。

【问题讨论】:

  • 到目前为止你还有什么工作要做吗?
  • python 脚本是期望从标准输入读取数据,还是期望获取文件名参数?

标签: bash terminal


【解决方案1】:

您可能想要使用输入重定向:

python script.py < inputFolder/input_file.csv > outputFolder/output_file.csv

您使用的是什么操作系统? \ 是 Windows 目录分隔符。 Linux 使用/

【讨论】:

  • 您应该坚持使用camelCasesnake_case,但不要混合使用这两种风格。
猜你喜欢
  • 2018-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多