Can not rename a single file using python [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to rename a file in downloads folder and I get (I translate)
OSError: [WinError 123] Syntax of filename, catalog name or label is wrong: 'C:\\Users\\Miaoulis\\Downloads\\feed.xml' -> 'C:\\Users\\Miaoulis\\Downloads\\VECTOR_03-10-2020 16:49_new.xml'
using windows 10, Kaspersky Internet Security and the following
import os
src = 'C:\\Users\\Miaoulis\\Downloads\\feed.xml'
dst = 'C:\\Users\\Miaoulis\\Downloads\\VECTOR_'+str(file_date)+'_new.xml'
if os.path.isfile(src):
os.rename(src, dst)
thank you

The destination file name has a colon. Try renaming without colon.

Related

Why does df.to_pickle() return an error, while df.to_excel() does work fine [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 17 days ago.
Improve this question
When I try to pickle a dataframe, I get an error:
df.to_pickle(r"C:\Users\TomCruise\workspace")
> [Errno 13] Permission denied: 'C:\\Users\\TomCruise\\workspace'
The folder called "workspace" is my current workspace. If I try df.to_excel("file name.xlsx") a file is correctly stored in the folder "workspace" with path C:\Users\TomCruise\Workspace.
Why does to_pickle return an error stating it does not have the permission to access the folder in the path, when to_excel works perfectly fine?
Try add the file extention
df.to_pickle(r"C:\Users\TomCruise\workspace\filename.pkl")

AttributeError: module 'random' has no attribute 'randit' [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have seen the answers/recommendations for this questions.
I promise that I do not have a random.py file named on my computer. I have searched it, tried to delete it will the send2trash module as well as os.unlink. I simply do not get it. I am unable to call the random.randit() because of this issue. Also when I call os.cwd() the file path does not exist on my computer. I again, have no idea how this is possible.
The code would be random.randint(), not random.randit()

How to input a path by python 3? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
import xlrd
path = input('enter the path')
data = xlrd.open_workbook(r'path)
The program doesn't work ,the reason is 'path' does not exist.
So what is the correct way to write the code?
import xlrd
path = input('enter path:')
data = xlrd.open_workbook(path)
This is supposed to work, your issue is you pass a string that just says 'path' instead of the path variable that has the path.
You can use a relative or absolute path.

Python (Pycharm): [Errno 2] No such file or directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm pretty new to Python and I'm trying to read a CSV file with Pandas. However I get the following error:
C:\Python\python.exe "C:/Users/Niels Hoogeveen/PycharmProjects/HelloWorld/HelloWorld.py"
C:\Python\python.exe: can't open file 'C:/Users/Niels Hoogeveen/PycharmProjects/HelloWorld/HelloWorld.py': [Errno 2] No such file or directory
I tried the absolute path, but I get the same error time and time again.
See the screenshot below.
What do I need to do?
screenshot of my code and error
Your file is called test.py instead of HelloWorld.py
By the way, it's possible that '/' must be replaced by '\'
Your Python file's name is not HelloWorld.py, it is test.py. :) Just change the name in the PyCharm terminal and it should start to work.

Python write to file creating empty file [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
When I try to create and write to a text file only an empty file is created. Here is the code:
controlCheck = open("resources/controlType.txt", "w")
controlCheck.write("controller")
controlCheck.close()
Any idea what the problem is? Its driving me crazy.
Whenever python writes a file, it erases all former data.There are ways to get around it, such as using: what is talked about here: Opening a file for append

Categories

Resources