this function is being called by the way the file is correct ‘paragraphs.txt’ but when it runs it finishes with no errors but doesn’t write anything to the file git files file with problem: https://github.com/K-972/english_helper write to file test: https://github.com/K-972/file-write-test i have wrote a script separately to test writing to a file and it worked so i don’t know why
I have a text file in this format: I want to check if the image name is the same and then concatenate those lines into one line with the following format: I have tried something like this but don’t know how to do the actual comparison and also don’t quite know what logic to apply since the first line_elements will
I’m trying to copy over a bunch of folders, read from a txt file into another folder . How do I do this? I’m using python in Linux e.g this txt file has the following folder names and I want to copy these folders and their contents to a folder called duplicate-folder How do I do this? I tried the
I have a text file in this format: I want to remove the lines that don’t have a [number1,number2,number3,number4,1] or [number1,number2,number3,number4,5] ending and also strip the text line and remove the [blocks] -> [number1,number2,number3,number4,number5] that don’t fulfill this condition. The above text file should look like this in the end: My code: I have tried something like this and it
I have a .txt file that says “NAMES,” “POINTS” and “SUMMARY” in capital letters, each followed by lines containing data. Each of these three groups is separated by an empty line: My goal is to create three separate sets of names, points and summary. I already created a set of names using the following code (which outputs a set of
As you can read, the function validate_data should check the imported file for corrupt and valid lines, then append them to the correct list, and print them. It works, except that, as you can probably see, the lines will not print in a single line. I’m sure I have to make two other lists to append the correct data into
I’d like to stream data directly to disk. One way of doing that is simply to read data and write to file, but I also want to minimalize RAM usage. I’ve figured out some manual way of doing that: Do I really have to manually load stream part by part? If so, how can I determine optimal value of BUFFER_SIZE?
I’m currently tasked with creating a CSV file from a list of dictionaries where the headers are the dic keys and the rows the dic values Ex. Output would be a CSV File: We’re not allowed to use dictwriter/csv/pandas and have to do it the naïve way. I currently have the keys gathered, but am struggling with trying to split
My old friend and I have been trying to save our chat histories recently for the nostalgia and the memories. Google chat history saves in a latest-oldest order. I’d like to make it to oldest-latest as well as change the pattern of the text. Any idea how I can implement this in Python? For reference this is the Hangouts file.
I’ve a code which creates an excel in a specific field with 3 sheets: I need the file name to become a varaible and I’ve done this: Even though the file_name is variable now, I get an error with the sheets creation and It’s blowing my mind. Any other way to make it variable? Thanks Answer Using fr’ instead of