How to delete a given line in a text file?
Posted: Fri Aug 24, 2018 12:22 pm
How to delete a given line in a text file?
How to remove the 1st line in a txt file?
How to remove the 1st line in a txt file?
Donnay Software Web Forums
http://donnay-software.com/DONNAY/
Code: Select all
#INCLUDE "dcdialog.CH"
FUNCTION Main( cInFile, cOutFile, cLineToDelete )
LOCAL nHandle1, nHandle2, aText[0], cLine, nLineToDelete, nLine
nLineToDelete := Val(cLineToDelete)
nHandle1 := DC_TxtOpen(cInFile)
nHandle2 := FCreate(cOutFile)
nLine := 1
DO WHILE !DC_TxtEof(nHandle1)
cLine := DC_TxtLine(nHandle1)
IF nLineToDelete <> nLine
FWrite(nHandle2,cLine+Chr(13)+Chr(10))
? cLine
ELSE
? '<<<<<<<< Line ' + cLineToDelete + ' has been deleted >>>>>>>>>'
ENDIF
DC_TxtSkip(nHandle1)
nLine++
ENDDO
FClose(nHandle1)
FClose(nHandle2)
wait
RETURN nil
Code: Select all
[PROJECT]
COMPILE = xpp
COMPILE_FLAGS = /q /w /rDCLIPX.LIB
GUI = yes
LINKER = alink
DelLine.XPJ
[DelLine.XPJ]
DelLine.EXE
[DelLine.EXE]
DelLine.PRG
Code: Select all
mFileName = SUBSTR(aFileName[ff], 1, AT('.',aFileName[ff])-1)
CLOSE ALL
USE (mFileName) EXCLUSIVE NEW
SELECT (mFileName)
********** Открыть процесс печати выходной формы
set device to printer
set printer on
set printer to (mFileName+'.csv')
set console off
?'SK_ID_CURR,TARGET'
DBGOTOP()
DO WHILE .NOT. EOF()
?ALLTRIM(ID)+','+ALLTRIM(STR(ROUND(PROB,1)))
DBSKIP(1)
ENDDO
********** Закрыть процесс печати выходной формы
Set device to screen
Set printer off
Set printer to
Set console on
Code: Select all
SK_ID_CURR,TARGET
100001,0.9
100005,0.8
100013,0.7
100028,0.3
100038,0.8
100042,0.5
100057,0.8
100065,0.7
100066,0.7
100067,0.8
100074,0.8
100090,0.8
100091,0.8