AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Removing Third Value in CSV File ? how to ?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Shalow
Guest





PostPosted: Tue Jul 01, 2008 6:35 pm    Post subject: Reply with quote

totana wrote:
try this:
Code:
f1= File.csv
f2 = NewFile.csv
filedelete, %F2%
loop,read,%F1%
{
stringsplit,BX,A_LoopReadLine,`,
fileappend, %bx1%`,%bx2%`,%bx4%`n, %F2%
}


(tested)


when i test this, in some cases, i get a break at the end of the file, because of the break after bx4, and if i don't put the break, the lines get all tangled up

what do i do ?
Back to top
Shalow
Guest





PostPosted: Tue Jul 01, 2008 6:53 pm    Post subject: Reply with quote

Ok, the error was not in this script, but the other one :

Code:
TXT_Replace(TextFile, SearchText, ReplaceText=""){
Original := A_BatchLines
SetBatchLines, -1
    TextFile := (SubStr(TextFile,1,1)="!") ? (SubStr(TextFile,2),OW=1) : TextFile
    FileRead, Str, %TextFile%
    StringReplace, Output, Str, %SearchText%, %ReplaceText%, All
    If OW {
        FileDelete, %TextFile%
        FileAppend, %OutPut%, %TextFile%
    }
    Else {
        SplitPath, TextFile,, Dir, Ext, Name
        FileDelete, % Dir "\" Name "_copy." Ext
        FileAppend, %OutPut%, % Dir "\" Name "_copy." Ext
    }
SetBatchLines, %Original%
}


this duplicate remover is not perfectly working because it adds an extra line if there are no duplicates in the file.
Back to top
Shalow
Guest





PostPosted: Tue Jul 01, 2008 7:24 pm    Post subject: Reply with quote

totana wrote:
try this:
Code:
f1= File.csv
f2 = NewFile.csv
filedelete, %F2%
loop,read,%F1%
{
stringsplit,BX,A_LoopReadLine,`,
fileappend, %bx1%`,%bx2%`,%bx4%`n, %F2%
}


(tested)


the thing is, if i do this twice in a row for two different files, the last line of the first file is appended to the second file, even thought i specified different variables, f3, f4 and f1, f2

anyone know why ?
Back to top
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Tue Jul 01, 2008 8:56 pm    Post subject: Reply with quote

I didn't tested , but I think the variable should be empty in the loop before reading
Code:
loop,read,%F1%
{
BX1=
BX2=
BX3=
BX4=
stringsplit,BX,A_LoopReadLine,`,
fileappend, %bx1%`,%bx2%`,%bx4%`r`n, %F2%
}


if you use separator = > ;
Quote:

stringsplit,BX,A_LoopReadLine,`;
fileappend, %bx1%;%bx2%;%bx4%`r`n, %F2%
Back to top
View user's profile Send private message
Shalow



Joined: 01 Jul 2008
Posts: 23

PostPosted: Tue Jul 01, 2008 9:06 pm    Post subject: Reply with quote

ok, thanks for the emptying, it worked.

don't understand the separator thingy.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group