Duplicate lines

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
canis
Posts: 9
Joined: Fri Jan 18, 2008 5:45 pm

Duplicate lines

Post by canis »

For example I have this text:

line1
line2
line3
...
lineN


I need it to become:

line1=line1
line2=line2
line3=line3
...
lineN=lineN


I use this perl pattern: search ^(.*)$ - replace with $1=$1 (thanks to support team), but I have this:

line1
=line1
line2
=line2
line3
=line3
....


How to join lines by pair?
dfhtextpipe
Posts: 988
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Check the Perl matching options

Post by dfhtextpipe »

Turn off . matches New Line
Last edited by dfhtextpipe on Fri Jan 18, 2008 8:36 pm, edited 1 time in total.
canis
Posts: 9
Joined: Fri Jan 18, 2008 5:45 pm

Post by canis »

Excuse me, where is it?

P.S. ok, I've found. But lines have no dots at the and.
dfhtextpipe
Posts: 988
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Solution found - tested with some random data - this works

Post by dfhtextpipe »

Use the copy fields filter, with an equals sign as the custom delimiter....

Code: Select all

TextPipe Single User Edition

Filter Title: Solution

Filter List
-----------
Filter options
|  [ ] Log to file
|  [X] Append to logfile
|  Log filename: textpipe.log
|  Threshold 500
|
|--Input from file(s)
|     [ ] Confirm before processing each file
|     [ ] Confirm before processing read/only files
|     [ ] Delete input files after processing
|     Process binary files
|   
|--Comment...
|   
|--Copy fields:=-delimited field 1 .. field 1 copy to 2
|     Delimiter Type: 5
|     Custom delimiter: =
|     [ ] Has Header
|   
+--Output to file(s)
      [ ] Only update date on changed files
      [X] Keep original file's date and time
      [ ] Append mode
      [X] Change extension to: .try.txt
Restrictions
You would need to ensure that the original data does not contain any = characters.
If this is not true, you could choose a different delimiter, one that your data never contains, then use an exact replace filter to change it from that to =.
canis
Posts: 9
Joined: Fri Jan 18, 2008 5:45 pm

Post by canis »

Thanks, I've just replaced carriage return with "nothing".
Post Reply