Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Append root directory folder and subdirectory to filename
Post: RE: Append root directory folder and subdirectory ...

(Aug-05-2020, 05:52 PM)deanhystad Wrote: I suggest not renaming the files and instead printing out the path/filename you would use if you did rename. This will quickly point out where you are makin...
glittergirl General Coding Help 9 4,358 Aug-05-2020, 06:06 PM
    Thread: Append root directory folder and subdirectory to filename
Post: RE: Append root directory folder and subdirectory ...

(Aug-05-2020, 04:21 PM)bowlofred Wrote: In the place of path.split(dirpath)[-1] When I run the following code, the text files in my folder just disappears. import os from os import walk, path, rena...
glittergirl General Coding Help 9 4,358 Aug-05-2020, 05:23 PM
    Thread: Append root directory folder and subdirectory to filename
Post: RE: Append root directory folder and subdirectory ...

(Aug-04-2020, 10:00 PM)bowlofred Wrote: By doing path.split(dirpath)[-1], you're asking for "the last component of the path", which is a str. If you just remove the bracket, you're asking for all c...
glittergirl General Coding Help 9 4,358 Aug-05-2020, 04:19 PM
    Thread: Append root directory folder and subdirectory to filename
Post: RE: Append root directory folder and subdirectory ...

(Aug-04-2020, 08:02 PM)bowlofred Wrote: In your rename, you're asking for only the final component of the path path.split(dirpath)[-1] If you want all the components, then you'll need to grab them ...
glittergirl General Coding Help 9 4,358 Aug-04-2020, 09:44 PM
    Thread: Append root directory folder and subdirectory to filename
Post: Append root directory folder and subdirectory to f...

I have a few text files, such as a.txt and b.txt, in a location called dir/test2. I would like to rename those two files to dir_test2_a.txt and dir_test2_b.txt. The code I have so far only renames th...
glittergirl General Coding Help 9 4,358 Aug-04-2020, 06:51 PM
    Thread: Error with SpeechRecognition module
Post: RE: Error with SpeechRecognition module

(Aug-03-2020, 09:15 PM)Gribouillis Wrote: At the beginning of the script, write import sys print(sys.executable) print(sys.version_info) print(sys.path) sys.exit(0)and post the output here. Thank yo...
glittergirl General Coding Help 3 2,878 Aug-04-2020, 02:11 PM
    Thread: Error with SpeechRecognition module
Post: Error with SpeechRecognition module

I am following this tutorial to transcribe audio. First, I installed all the modules and program before running python3 transcribe.py, and transcribe.py contains the following code. import speech_re...
glittergirl General Coding Help 3 2,878 Aug-03-2020, 09:01 PM
    Thread: Output CSV file with filepath and file contents
Post: RE: Output CSV file with filepath and file content...

After some googling, this is the correct answer: import csv from pathlib import Path with open('big.csv', 'w', encoding='Latin-1') as out_file: csv_out = csv.writer(out_file) csv_out.writer...
glittergirl General Coding Help 1 1,753 Aug-03-2020, 01:50 AM
    Thread: Output CSV file with filepath and file contents
Post: Output CSV file with filepath and file contents

I want to output a CSV file with the filepath and file content in the directory. I tried the following code, but it only iterates through files in the folder. I want it to iterate through the entire d...
glittergirl General Coding Help 1 1,753 Aug-03-2020, 12:00 AM
    Thread: How do I read the HTML files in a directory and write the content into a CSV file?
Post: How do I read the HTML files in a directory and wr...

I am trying to read all the HTML files in a directory and write them into a CSV file. Each row in the CSV file will contain the contents of one HTML file. I seem to be able to only read one HTML file...
glittergirl General Coding Help 1 2,593 Sep-23-2019, 01:21 AM
    Thread: How do I turn a directory of HTML files into one CSV?
Post: RE: How do I turn a directory of HTML files into o...

(Sep-21-2019, 04:04 PM)woooee Wrote: Quote:prints all four filenames in the "filename" column You put all of the file names in the list, not just one. lines = [[files, html]] I would also suggest t...
glittergirl General Coding Help 2 1,809 Sep-21-2019, 05:33 PM
    Thread: How do I turn a directory of HTML files into one CSV?
Post: How do I turn a directory of HTML files into one C...

I am currently trying to do the following: 1. Identify all the files that have the text "business class" in it. 2. Print all the files that have the text "business class" in it to a CSV containing c...
glittergirl General Coding Help 2 1,809 Sep-21-2019, 02:33 PM
    Thread: How do I get rid of the HTML tags in my output?
Post: How do I get rid of the HTML tags in my output?

How do I remove HTML tags from the following code? This is what I've tried: import collections import itertools import sys import csv import glob import re def striphtml(data): p = re.compile(r'...
glittergirl Web Scraping & Web Development 1 3,728 Aug-05-2019, 07:21 PM
    Thread: How do I extract specific lines from HTML files before and after a word?
Post: How do I extract specific lines from HTML files be...

I am trying to extract the 10 lines before and after the word "apple" from a directory (with subdirectories) full of HTML files. I want to print out the lines into a CSV file. Ideally, the CSV file wi...
glittergirl Web Scraping & Web Development 1 5,103 Aug-05-2019, 05:45 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020