AutoHotkey Community

It is currently May 24th, 2012, 1:47 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: May 24th, 2007, 6:19 pm 
How I can remove duplicate word in a .txt


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 6:31 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8620
Location: Salem, MA
Read a txt file and delete duplicate lines?
Duplicate lines in a file

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 6:43 pm 
FileSelectFile, FileName, 1
FileRead, OutputVar, %FileName%
Sort, OutputVar, N
FileAppend, %OutputVar%, y.txt
Loop, Read, y.txt,
{
If Var <> %A_LoopReadLine%
FileAppend, %A_LoopReadLine%`n, z.txt
Var = %A_LoopReadLine%
}
FileDelete, y.txt

with this i still got duplicate word.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 6:45 pm 
ie: word1
word2
word1 --->erase
word1 --->erase
word3
word4
word4 --->erase



I want that found in all the .txt same word, and erase if a word is already found.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 6:58 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8620
Location: Salem, MA
read further in the threads:

Code:
FileRead, Text, Source.txt
Sort, Text, U ; Unique
FileAppend, %Text%, Target.txt

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 7:21 pm 
thats write 2x each word.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 7:36 pm 
I used this correctly and thats write 2x each word.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2007, 10:44 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Code:
text =
(Join`r`n
word1
word2
word1
word1
word3
word4
word4

)
; Above is same as FileRead text, source.txt

Sort text, U
MsgBox %text%
It works, you have to ensure last line has `r`n at the end.
Of course, if you FileAppend to the original file, you will get redundancy...

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 25th, 2007, 12:22 am 
yah i fileappend thats :\


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 25th, 2007, 9:32 am 
To change the original file, you have to first delete it, then do FileAppend.
Hopefully someday we will have a FileOverwrite command...


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google [Bot], Google Feedfetcher, hd0202, jyloup, tantalus00, Yahoo [Bot] and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group