Batch - extract 3rd column from CSV

February 12, 2010 at 23:52:11
Specs: Windows XP
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.

See More: Batch - extract 3rd column from CSV

Report •

February 13, 2010 at 03:15:30
:: EX3.BAT Usage: ex3 "Path_Name\File_Name"
@echo off > ""
for /F "tokens=3 delims=," %%j in ('type "%~1"') do echo.%%j>> ""
:: End_Of_Batch

Example: ex3 "C:\My Folder\CSV File.txt"

The result for the above example will be in "CSV".

Report •

February 17, 2010 at 08:29:30
That was perfect. I know this was just a simple little item, but it was very helpful. I have been trying to learn a bit more simple programming to get my feet wet and this was a missing link in a process that I needed. I modified it slightly for my purposes so it was not command line driven since the name of the text file will always be the same. Thanks for the help.

set CSV=Hazard_Report.txt
for /F "tokens=3 delims=," %%j in (%CSV%) do echo.%%j>> "Hazard_Report.bat"

Report •
Related Solutions

Ask Question