• XSS.stack #1 – первый литературный журнал от юзеров форума

hello who knows how to remove empty || in pipe delimited txt file

BestDealz

ripper
КИДАЛА
Регистрация
26.05.2023
Сообщения
65
Реакции
17
Пожалуйста, обратите внимание, что пользователь заблокирован
example of my issue im having
name|adrress|dob|zip||country|||


how can i remove that so it ends up
name|adrress|dob|zip|country

i would do it manually but there's literally thousands of lines.
 
Пожалуйста, обратите внимание, что пользователь заблокирован
example of my issue im having
name|adrress|dob|zip||country|||


how can i remove that so it ends up
name|adrress|dob|zip|country

i would do it manually but there's literally thousands of lines.
You can use a regular expression (regex) to remove the empty pipes in the pipe delimited text file. Here's an example of how you can do it using Python:
import re

# Read the file
with open('filename.txt', 'r') as f:
file_content = f.read()

# Remove empty pipes
new_file_content = re.sub('\|+', '|', file_content)

# Write the updated content back to the file
with open('filename.txt', 'w') as f:
f.write(new_file_content)

In this code, I used the re.sub() method from the Python re module to replace one or more consecutive pipe symbols (\|+) with a single pipe symbol (|). This effectively removes any empty fields between two valid fields.

Make sure you replace 'filename.txt' in the code with the actual filename/path of your pipe delimited text file.


ChatGPT is always helpfull :)
I Hope this helped you a bit.
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх