504 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
0
answers
78
views
How is import os.path possible? [duplicate]
Since os is a module instead of a package, import os.path should fail. For comparison:
>>> import os.sys
Traceback (most recent call last):
File "<python-input-0>", line 1, ...
0
votes
0
answers
93
views
os.path does not work with a /dev/ttyUSB0
I have a simple script to check if a USB device (UART) is plugged in.
(OS = Ubuntu 22.04, Python 3.10).
import os
path = os.path.join('dev', 'ttyUSB0')
print(f'DBG exists: {os.path.exists(path)}')
...
-3
votes
1
answer
125
views
For loop not writing images
I'm attempting to write a for loop that opens each image in a folder, processes it, and then outputs it back into the same folder. The problem is, when I run the script, nothing happens. I just see ...
1
vote
1
answer
91
views
Unclear behaviour of pinecone's load_dataset
In the following program, I have the three functions get_dataset1, get_dataset2, and get_dataset3 that are all very similar. They only differ in when they call len(dataset) and os.path.join = tmp.
The ...
0
votes
2
answers
56
views
Extracting file paths, occasionally returns special characters (~$) in file names
When extracting file paths, not all but a few results are returned that contain special characters ~$ at the start of the file name. I am looking to compare these file paths with another list, thus ...
0
votes
1
answer
91
views
Python - os.path.exists for jpg
I tried to read jpg pictures, but the path was always not found even though the path was correct. So I checked with os.path.exists. The image is called "ralf". And for
os.path.exists("C:...
-2
votes
1
answer
82
views
Naming of file while saving with extension
How can I save a file with the name as: oldname+"_new"+extension in an elegant way?
I currently do:
ext = os.path.splitext(file)[1]
output_file = (root+'/'+ os.path.splitext(file)[0]+"...
1
vote
2
answers
490
views
How To Get Relative Paths When Zipping multiple files in Python on Windows
I am attempting to create a function that automatically runs through a folder and puts all of the files into a single .zip file and while I have it working, it is creating a nest of folders inside the ...
1
vote
2
answers
983
views
os.path.isfile returns True even though specified file does not exist at working directory
I have a project that i wrote with OOP on separated modules. First module that gets imported and called by an object is "DataLibrary".
DataLibrary module's data source is an .xlsx file ...
1
vote
2
answers
57
views
How to make sure that information from one file is duplicated into several text documents, without specific lines
We need a code in pyhon that will create several text documents in which only information about the letter v will be written, and after the letter f create a text document with the next letter v, the ...
0
votes
0
answers
95
views
Unable to access files using os functions
I've been working to create a script that compares CSV files (based on this post: https://medium.com/@satsundev/compare-two-csv-using-python-92a0a23d7f54) but have run into an issue where Python can't ...
0
votes
0
answers
29
views
check updates on each subfolder of subfolders dcmp python
I am trying to build a back-up script in order to back-up all my pc to an external ssd(lost all my data 3 times by now).
It works great for the files and main folders but until now I am not able to ...
0
votes
2
answers
798
views
removing back dots dir from path's prefix
I have two paths.
path1 = /users/fida/data_lake/data/archived/09142023
path2 = /users/fida/data_lake/data/localpublished/SPTTES/End_to_End_Edit_Schedule/2022-08-03_11_22_03.kp
Output Im trying to get ...
-1
votes
1
answer
1k
views
How to delete a file? Getting "The process cannot access the file because it is being used by another process" error
Update: I am not getting the error when hosting this online. Able to delete normally. Leaving this up incase there are any useful answers for running locally on windows pc.
Context: I download a pdf ...
0
votes
1
answer
114
views
python f-string and regular expression to generate customized path of a file in a directory
Given:
Files in a working directory:
WKDIR = "/scratch/project_2004072/Nationalbiblioteket/dataframes"
$ ls -l
...