I am working on a python code that is supose to search a directory and see if a file in the directory has a _add_ or a _update_ and to change a few fields in my code that call the add and updata and change the directory name to match it. Is there a way to do that which is simple and easy for a new python coder to understand. If you need my code i will post it also
|+0 forum 2|
Hey all, I have the following code that is working fine; basically it finds all files on my desktop and then prints the specific ones that I am looking of. I save all files to my desktop and the files contain the clients name so I figure once a week I can clean my desktop by sending the files off to where they live in the correct directories. Here is what I have so far... import glob import os os.chdir("d:\Desktop") for files in glob.glob("*.*"): x = str(files).lower() if 'client_name' in x: print x The next bit is to gt the …
|+0 forum 3|
I have a directory with hundreds of CSV files in it. Many of the files have synonyms for words that I no longer want. I want to replace all of the synonyms with approved words. For example some CSVs have synonyms like `vial` `jug` `canteen` `urn` etc and I want to replace all of those with the word `bottle`. How would I do this? I know I can use `glob` to go through all of the files and I found http://stackoverflow.com/questions/17536138/replace-multiple-strings-in-csv-file?lq=1 but that does not really do what I need. Does anyone have any ideas?
|+0 forum 2|
>I need to take a list of files and remove a '.2' from a line in each file. I then need to rewrite the file without the '.2'. Using the code below I am >able to take a single file and do exactly what i need to but when trying to use glob.glob to rewrite a number of files I run into problems and >was wondering if anyone could help. >when i run this code i get the following error. >File "learn.py", line 15, in module >TypeError: coercing to Unicode: need string or buffer, list found
|+0 forum 11|
Hi all, I apologise in advance if this is too simple, but I've been searching around for a good hour or two now, and I can't quite get my head around this. Basically, I'm looking to teach myself Python (3), and one of the things I'm trying to do is put together a simple script that could recursively search an entire drive for a file of a given extension. I've been looking around, and figured that I'll probably need to use os.walk to recursively search the drive, along with finding other snippets here and there about what I should do. …
|+0 forum 5|
Reusable Code Snippet List Filenames and Pathnames (Python)
A short look at creating lists of file names or full path names using the versatile Python module glob. Glob follows the standard wildcard protocol.
|+1 forum 0|