If it didn't work, appeal to our future overlord aka AD(artificial dumbness).😉
ChatGTP is a dead horse for programming. I don't advise any normal person to do any serious things with it.
Doesn't see many things at once, you have to draw him exactly what you want, the possibility of it predicting what you want is small... Example.....
I tell him that I want him to separate segments from the text file...
segments are separated by a vertical line |
in file 1.txt
text1 | text2 | text3| text4
i want to get in file 2.txt
text1 | text2 | text4
from file 1.txt
and tells me dead serious here is a python script for you:
import re
# Function to process the text and extract the desired parts
def extract_text(input_file, output_file):
with open(input_file, 'r') as f:
input_text = f.read()
# Regular expression pattern to capture the desired text
pattern = r'(\b\w+_\w+\b)\s*\|\s*(\b\w+_\w+\b)\s*\|\s*\w+\s*\|\s*(\b\w+_\w+\b)\s*\|'
matches = re.findall(pattern, input_text)
# Create the new text format from the extracted matches
output_text = "\n".join([" | ".join(match) for match in matches])
# Write the new text to the output file
with open(output_file, 'w') as f:
f.write(output_text)
# Example usage
input_file = '1.txt'
output_file = '2.txt'
extract_text(input_file, output_file)
The script does nothing....I have a blank file.
Too much dulls and complicates it...
The solution is in bash one line
cat 1.txt | cut -d '|' -f1,2,4 > 2.txt
He says you are right, sorry for the confusion….
