I have a folder with about 200 txt files and they are poems with different file names.…
- User
I have a folder with about 200 txt files and they are poems with different file names. Can you please help me write a bash script to extract each .txt poem file to a row of a csv standard AI language model training dataset. There is ONLY ONE COLUMN! THE ONLY ONE COLUMN is "text". So, basically, you cat all the files in that directory and put them into each row of the "text" column.
- Assistant
Here's a bash script that should do what you're asking for:
#!/bin/bash # Set the path to the directory containing the text files path="path/to/directory" # Iterate over all text files in the directory for file in "$path/*.txt" do # Extract the text from the file text=$(cat "$file") # Write the text to a new CSV file echo "text,${file//\//}\n" > "$output_file" done
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.