Delete the first line of a csv or txt file

1

I thank you in advance:

In a file called crear mlt that is located in a root folder

  

"C: \ Python27 \"

from which I can not move this file when creating CSV or TXT extension files within it, a line that hinders is created, which is the first line.

I created this source code but it does not point to the internal url

  

C: \ Python27 \ Output \ MLT \ humf_foot * .csv

That is, I order that you delete the line to the CSV file which is in a different folder of the bat file. Here I leave a preview to see who helps me. Thanks.

If there is another language (be it java), delete it ONLY the first line I appreciate it.

Personally I prefer bat, here I leave the advance of my script:

echo @echo off > dds.bat
echo (  >> dds.bat
echo ECHO 1d>> dds.bat
echo ECHO ^E>> dds.bat
echo ^) ^| EDLIN ^/^B 3dc.csv ^> nul 2^>^&^1 >> dds.bat
move dds.bat C:\Python27\Output\MLT\humf_foot\dds.bat
CALL C:\Python27\Output\MLT\humf_foot\dds.bat
::DEL /q C:\Python27\Output\MLT\humf_foot\dds.bat
    
asked by Juan Carlos Villamizar Alvarez 25.12.2016 в 21:48
source

1 answer

1

Good morning, I understand that what you are looking for is to erase the first line of a .csv file with a windows program .bat, right?

Here is my proof: program.bat:

@echo on
cd C:\Users\%USER%\Desktop
type HOLA.csv
pause
for /F "skip=1 tokens=*" %%i in (HOLA.csv) do @echo %%i >> HOLA2.csv
pause
echo se ha modificado el archivo
DEL HOLA.csv
REN HOLA2.csv HOLA.csv
type HOLA.csv

To understand it a bit with a for I am going to read the .csv file line by line, with skip I will skip the first line of the file and with tokens will read all the items of the same line. Then I save all the items of the same line in one variable and register it in another file (thus, for each line of the file, except the first one). Then, I delete the old file and rename the one I just created.

CMD RESULT:

C:\Users\%USER%\Desktop>type HOLA.csv
PRIMERA LINEA, REGISTRO 1, REGISTRO 2,
SEGUNDA LINEA, REGISTRO 3, REGISTRO 4,
TERCERA LINEA, REGISTRO 5, REGISTRO 6,

C:\Users\%USER%\Desktop>program.bat

C:\Users\%USER%\Desktop>cd C:\Users\%USER%\Desktop

C:\Users\%USER%\Desktop>type HOLA.csv
PRIMERA LINEA, REGISTRO 1, REGISTRO 2,
SEGUNDA LINEA, REGISTRO 3, REGISTRO 4,
TERCERA LINEA, REGISTRO 5, REGISTRO 6,

C:\Users\%USER%\Desktop>pause
Presione una tecla para continuar . . .

C:\Users\%USER%\Desktop>for /F "skip=1 tokens=*" %i in (HOLA.csv) do @echo %i  1>>HOLA2.csv

C:\Users\%USER%\Desktop>pause
Presione una tecla para continuar . . .

C:\Users\%USER%\Desktop>echo se ha modificado el archivo
se ha modificado el archivo

C:\Users\%USER%\Desktop>DEL HOLA.csv

C:\Users\%USER%\Desktop>REN HOLA2.csv HOLA.csv

C:\Users\%USER%\Desktop>type HOLA.csv
SEGUNDA LINEA, REGISTRO 3, REGISTRO 4,
TERCERA LINEA, REGISTRO 5, REGISTRO 6,
    
answered by 26.12.2016 в 18:00