computing
  • 2

Hello, How To Delete 2nd Line Drom a Csv Using a Bat?

  • 2

Hello,

I have a CSV that I need to delete a line just below the Header (the second row of the csv) using a bat file. However, I have no idea how to do this.

Does anyone have an idea how this can be done?

Thank you for your help

Share

1 Answer

  1. rem set col.heads=1,2,3,4,5,etc or whatever you want, or nothing
    ECHO.col.heads>file2.csv
    MORE +3 file1.csv>>file2.csv

    might work, IF your csv file is not unicoded, and IF your line-breaks are recognized by MORE. If your app REALLY has to have column heads, you can just echo them to the file before the MORE statement. You should take a look at your csv file to see if it’s Unicode, and what line-breaks it uses. I recommend EDIT /70 to examine the file because it shows Unicode interstices as well as line-break char.s
    Another way is to use either FIND or FINDSTR with line numbers and then exclude those line numbers from your output. f/e: FIND /N /V “” file.csv|FIND /V “[3]”
    would exclude line 3 from output. If “[3]” occurs in the base-file stream, then use : FIND /N /V “” file.csv|FINDSTR “^\[3\]”
    which will limit [3] to the beginning of the line and not mid-stream.

    message edited by nbrane

    • 0