Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 22, 2017, 02:15 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Manipulate lines in a txt file  (Read 3131 times)

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,986
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #25 on: March 04, 2017, 06:02 AM »
Well, an answer still missing is what to do if there is only one (1) phrase on a line. With current scripts the entire line will be deleted.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,986
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #26 on: March 04, 2017, 06:08 AM »
I was revising because I don't like forget the thread.
The forum has a 'Mark topic' button with several options to keep topics in sight... :)

Please reply to my previous answer :up:

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #27 on: July 24, 2017, 06:03 PM »
Sorry Ath.
I have to revise this post.
It's too late here now. I must be in bed and rest. I will revise !!!!!!

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 918
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #28 on: July 25, 2017, 02:13 PM »
 :) How about this one?

Fill inn source and target and save the script as Parts.ahk. Download and install Autohotkey to run the script.

Skrommel

source=Source.txt
target=Target.txt

#NoEnv
#SingleInstance,Force
SetBatchLines,-1

string:=""
FileRead,lines,%source%
Loop,Parse,lines,`n                                ; Split by line break
{
  StringSplit,part_,A_LoopField,.                  ; Split by period
  If part_0<3                                      ; 1 part
    line:=A_LoopField
  Else
    StringReplace,line,A_LoopField,%part_1%.,      ; Remove part 1
  line=%line%                                      ; Remove trailing space
  string.=line "`n"                                ; Add line break
}
FileDelete,%target%
FileAppend,%string%,%target%

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #29 on: August 02, 2017, 12:46 PM »
 :-*
Well, an answer still missing is what to do if there is only one (1) phrase on a line. With current scripts the entire line will be deleted.
I am going to try the script Skrommel
Where are you Ath ?
 ;D

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,986
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #30 on: August 02, 2017, 01:07 PM »
That stil doesn't answer the question... :'(

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #31 on: August 02, 2017, 02:24 PM »
Difficult question then !!!!!

i don't get any results with the script. I don't know what I am doing wrong.

I don't obtain nothin in the target.txt
I have the script in the desktop and the txt files too.

 :-[

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #32 on: August 09, 2017, 05:13 AM »
What can we do now ?
The post is opened but not working !!!!!!

 :-[

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,986
    • View Profile
    • Donate to Member
Re: Manipulate lines in a txt file
« Reply #33 on: August 09, 2017, 05:38 AM »
What can we do now ?
The post is opened but not working !!!!!!
Just as has happened before, it is quite difficult to understand what you are saying...

We had come to a working solution (post #18 in this thread, accepted by you in post #19), with only 1 question remaining:
- What should happen if a line in the file has only 1 period in it. Should that line be removed, or should it remain in the output?

Until this question is answered (I have asked 4 times before for an answer on this, this is the 5th and last time), any other questions (or solutions) here should be postponed, IMHO.