IPython 正在复制所有 csv 文件
IPython Copying all csv files
!find ~/DataFolder/CSVfolders -name "*.csv" > paths.txt
我的朋友使用此命令将所有逗号分隔值文件目录放入文本文件中,但是,我厌倦了使用以下命令来操作它
!find C:/directory/withdata -name "*.csv" > paths.txt
我是在jupyter notebook上做的,我第一次尝试把文件夹放在jupyter notebook文件夹之外,然后我把它放在jupyter notebook的文件夹里,它一直在说这两个东西。
访问被拒绝 - ....
找不到文件 -name
我对 IPython 设置中的这些 bash shell 命令有点陌生,我也有 windows OS,任何建议或来源将不胜感激。
两种解决方案:PowerShell 和 Python
您的代码无法正常工作,因为您必须使用 Windows 与 Unix find
等效的命令。
但是,考虑到您正在使用 Python,Python 代码可能是一个通用的解决方案。
问题
通过使用感叹号 !
,您正在调用系统的 shell。
因此,您执行的命令取决于系统。
例子
# Change the name of file1 to file2 in Unix-like systems
# But it doesn't work on Windows
!mv file1 file2
# The Windows equivalent
!ren file1 file2
您遇到了类似的问题。 Find
存在于类 Unix 和 Windows 中;但是,这两个命令的目的不同。
在 Windows 中,find
命令是一个过滤器,用于在输入数据流中查找包含或不包含指定字符串的行(即,它类似于 Unix 的 grep
命令) .
解决方案:使用 Windows PowerShell
阅读这篇文章后 thread 我提出以下使用 Windows PowerShell 的解决方案。
!Get-ChildItem -Filter "*.csv" -Recurse "C:/directory/withdata" > paths.txt
解决方法:用Python
即将推出...:)
!find ~/DataFolder/CSVfolders -name "*.csv" > paths.txt
我的朋友使用此命令将所有逗号分隔值文件目录放入文本文件中,但是,我厌倦了使用以下命令来操作它
!find C:/directory/withdata -name "*.csv" > paths.txt
我是在jupyter notebook上做的,我第一次尝试把文件夹放在jupyter notebook文件夹之外,然后我把它放在jupyter notebook的文件夹里,它一直在说这两个东西。
访问被拒绝 - ....
找不到文件 -name
我对 IPython 设置中的这些 bash shell 命令有点陌生,我也有 windows OS,任何建议或来源将不胜感激。
两种解决方案:PowerShell 和 Python
您的代码无法正常工作,因为您必须使用 Windows 与 Unix find
等效的命令。
但是,考虑到您正在使用 Python,Python 代码可能是一个通用的解决方案。
问题
通过使用感叹号 !
,您正在调用系统的 shell。
因此,您执行的命令取决于系统。
例子
# Change the name of file1 to file2 in Unix-like systems
# But it doesn't work on Windows
!mv file1 file2
# The Windows equivalent
!ren file1 file2
您遇到了类似的问题。 Find
存在于类 Unix 和 Windows 中;但是,这两个命令的目的不同。
在 Windows 中,find
命令是一个过滤器,用于在输入数据流中查找包含或不包含指定字符串的行(即,它类似于 Unix 的 grep
命令) .
解决方案:使用 Windows PowerShell
阅读这篇文章后 thread 我提出以下使用 Windows PowerShell 的解决方案。
!Get-ChildItem -Filter "*.csv" -Recurse "C:/directory/withdata" > paths.txt
解决方法:用Python
即将推出...:)