Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: [SOLVED] [listbox] Feed it with dict passed to class?
Post: RE: [listbox] Feed it with dict passed to class?
Thanks. The problem is that a listbox only accepts lists, not dictionaries. So I guess I'll have to keep two objects to work with a listbox. No biggie. |
|
Winfried |
General Coding Help |
3 |
240 |
May-13-2024, 03:07 AM |
|
|
Thread: [SOLVED] [listbox] Feed it with dict passed to class?
Post: [SOLVED] [listbox] Feed it with dict passed to cla...
Hello,
This is a newbie question.
Is it possible to feed a listbox with a dictionary (to get text + hidden value) passed through the class as input parameter?
import wx
class MoveItemListBox(wx.Li... |
|
Winfried |
General Coding Help |
3 |
240 |
May-12-2024, 11:57 AM |
|
|
Thread: [SOLVED] Loop through directories and files one level down?
Post: RE: Loop through directories and files one level d...
Thanks for the tip.
This finally works:
import os
for item in os.listdir(ROOT):
path = os.path.join(ROOT, item)
if os.path.isdir(path):
#print(item)
os.chdir(path)
print("===========... |
|
Winfried |
General Coding Help |
3 |
326 |
Apr-28-2024, 02:09 PM |
|
|
Thread: [SOLVED] Loop through directories and files one level down?
Post: [SOLVED] Loop through directories and files one le...
Hello,
Google didn't help.
On Windows, I need to loop through the directories one level below the start directory, and through all the files in each of those sub-directories. Sub-directories might c... |
|
Winfried |
General Coding Help |
3 |
326 |
Apr-28-2024, 01:10 PM |
|
|
Thread: Good way to ignore case when searching elements?
Post: Good way to ignore case when searching elements?
Hello,
In the files I need to work with, I notice that the values in the following meta line can be either lower-case or capitalized.
What would be the right way to convert them to lower-case regard... |
|
Winfried |
General Coding Help |
1 |
253 |
Apr-25-2024, 10:05 AM |
|
|
Thread: Right way to open files with different encodings?
Post: Right way to open files with different encodings?
Hello,
Some of the files could be Windows (latin1, iso9959-1, cp1252), others could be utf-8.
Is try/except the right way to do it?
#with open(file, 'r') as f:
#with open(file, 'r',encoding='utf-8'... |
|
Winfried |
General Coding Help |
2 |
329 |
Apr-23-2024, 08:49 AM |
|
|
Thread: Loop through all files in a directory?
Post: RE: Loop through all files in a directory?
Thanks much. The list I'll work on is tiny enough that I don't need a generator, but it's nice to know that it's available. Ditto for one liners and function annotations. |
|
Winfried |
General Coding Help |
10 |
588 |
Apr-23-2024, 07:52 AM |
|
|
Thread: Loop through all files in a directory?
Post: RE: Loop through all files in a directory?
Thank you.
(Apr-22-2024, 07:10 PM)Gribouillis Wrote: files = [os.path.join(d, f) for d, _, files in os.walk(root) for f in files]
I'm not used to one-liners. Am I correct in understanding it's the ... |
|
Winfried |
General Coding Help |
10 |
588 |
Apr-23-2024, 02:02 AM |
|
|
Thread: Loop through all files in a directory?
Post: Loop through all files in a directory?
Hello,
I need to find all the files located under a given directory, including all the sub-directories it may contain.
Is this a/the right way to do it?
import os
import glob
for filename in glob.... |
|
Winfried |
General Coding Help |
10 |
588 |
Apr-22-2024, 06:16 PM |
|
|
Thread: How to add multi-line comment section?
Post: How to add multi-line comment section?
Edit (since this forum doesn't support deleting a thread): My mistake. After using the (shift+)TAB keys, the script runs. Guess there were useless TAB characters.
-----------------
Hello,
Is there... |
|
Winfried |
General Coding Help |
1 |
254 |
Mar-24-2024, 01:33 PM |
|
|
Thread: Running Python script through Task Scheduler?
Post: RE: Running Python script through Task Scheduler?
I'll try that instead.
Thank you! |
|
Winfried |
General Coding Help |
8 |
705 |
Mar-10-2024, 07:24 PM |
|
|
Thread: Running Python script through Task Scheduler?
Post: RE: Running Python script through Task Scheduler?
What a pain…
What about using PyInstaller to compile the whole thing into a single binary? |
|
Winfried |
General Coding Help |
8 |
705 |
Mar-10-2024, 06:38 PM |
|
|
Thread: Running Python script through Task Scheduler?
Post: RE: Running Python script through Task Scheduler?
Thanks.
Yes, like I said, "The script works when launched manually."
After I followed the instructions above, I can see the screen flicker every minute (looks like a CMD window opens and closes real... |
|
Winfried |
General Coding Help |
8 |
705 |
Mar-10-2024, 06:03 PM |
|
|
Thread: Running Python script through Task Scheduler?
Post: Running Python script through Task Scheduler?
Hello,
This is my first try at running a Python (3.12.0) script through Windows 10's Task Scheduler… and it didn't work (as pretty much expected).
It's a simple script that 1) fetches a web page fro... |
|
Winfried |
General Coding Help |
8 |
705 |
Mar-10-2024, 03:39 PM |
|
|
Thread: [SOLVED] Correct way to convert file from cp-1252 to utf-8?
Post: RE: [SOLVED] Correct way to convert file from cp-1...
Turns out there's a lot easier solution: Just open the file and feed it to Beautiful Soup, which will take care of 1) converting data to utf-8 if needed, and add/edit the relevant meta line in the hea... |
|
Winfried |
General Coding Help |
8 |
1,192 |
Feb-29-2024, 12:30 AM |
|
|
Thread: [SOLVED] Correct way to convert file from cp-1252 to utf-8?
Post: RE: Correct way to convert file from cp-1252 to ut...
Looks like it.
After converting it to utf-8, chardet says a file is still "ascii with confidence 1.0" while both Notepad++ and Notepad2 say it's utf-8.
Bottom line: chardet doesn't seem reliable to ... |
|
Winfried |
General Coding Help |
8 |
1,192 |
Feb-26-2024, 06:19 PM |
|
|
Thread: [SOLVED] Correct way to convert file from cp-1252 to utf-8?
Post: RE: Correct way to convert file from cp-1252 to ut...
Using this code, the second run still says files are not in utf-8. It doesn't look like it's the right way to convert Windows files to utf-8:
for file in files:
rawdata = open(file, "rb").read()
... |
|
Winfried |
General Coding Help |
8 |
1,192 |
Feb-26-2024, 03:38 PM |
|
|
Thread: [SOLVED] Correct way to convert file from cp-1252 to utf-8?
Post: RE: Correct way to convert file from cp-1252 to ut...
The two lines you mean?
#data = open(file, "r").read()
#data.encode(encoding = 'UTF-8', errors = 'strict')
data = rawdata.decode(encoding=encoding)
#with open(file, 'w', encoding='utf-8') as outp:
wit... |
|
Winfried |
General Coding Help |
8 |
1,192 |
Feb-26-2024, 03:21 PM |
|
|
Thread: [SOLVED] Correct way to convert file from cp-1252 to utf-8?
Post: [SOLVED] Correct way to convert file from cp-1252 ...
Hello,
In a directory, I have a bunch of HTML files that were written in cp-1252 (ie. Latin1) that I need to convert to utf-8.
The following doesn't seem to work: After running the loop once, the se... |
|
Winfried |
General Coding Help |
8 |
1,192 |
Feb-26-2024, 02:28 PM |
|
|
Thread: [Faircom CTree] Access from Python?
Post: RE: [Faircom CTree] Access from Python?
I'll give it a shot, thank you. |
|
Winfried |
Data Science |
2 |
620 |
Feb-23-2024, 01:26 PM |