computing
  • 3

Batch – Extract 3rd Column From CSV

  • 3

I do not do much programming, but I need to simply extract the 3rd column from a csv file and save it to another text file.

—– Original CSV looks like this —–
834184.68161879,744798.14148857,copy Canal.htm generated_report\
831194.46197547,749775.63555287,copy Channel.htm generated_report\

—– Desired text file —-
copy Canal.htm generated_report\
copy Channel.htm generated_report\

The first 2 columns are X,Y coordinates, and I want to get rid of them. Thanks for the help.

Share

1 Answer

  1. :: EX3.BAT Usage: ex3 "Path_Name\File_Name"
    @echo off > "%~dpn1.new"
    for /F "tokens=3 delims=," %%j in ('type "%~1"') do echo.%%j>> "%~dpn1.new"
    :: End_Of_Batch
    

    Example: ex3 “C:\My Folder\CSV File.txt”

    The result for the above example will be in “CSV File.new”.

    • 0