Duplicate lines

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Duplicate lines

Postby canis » Fri Jan 18, 2008 6:27 pm

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?

DFH
Posts: 636
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Check the Perl matching options

Postby DFH » Fri Jan 18, 2008 6:44 pm

Turn off . matches New Line
Last edited by DFH on Fri Jan 18, 2008 8:36 pm, edited 1 time in total.

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

Postby canis » Fri Jan 18, 2008 6:49 pm

Excuse me, where is it?

P.S. ok, I've found. But lines have no dots at the and.

DFH
Posts: 636
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Solution found - tested with some random data - this works

Postby DFH » Fri Jan 18, 2008 8:33 pm

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

Postby canis » Fri Jan 18, 2008 8:56 pm

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


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 4 guests