|
Answer» Win XP HE SP.3+ Cmd.exe BATCH scripting.
I want to be able to extract the first n items of data from .Csv files hopefully without having to specify each item, i.E. specify the ENTIRE block rather than individual items.
The following script shows what I use and what I'd like to use to extract the leading 30 entries in the text line, can the Echo or any other command do this?
Note: A small .csv file will be created in your Temporary folder to facilitate running the script, it will be deleted on completion of the script.. If you do not want this facility to be used PLEASE do not run the script.
Current script: Code: [Select]@echo off cls setlocal enabledelayedexpansion
:: Create csv file.. for /l %%a in (1,1,80) do ( set column=!column!Col.%%a, ) set column=!column:~0,-1! echo !column!>%temp%\column.csv
:: Extract leading 30 columns.. for /f "tokens=1-30* delims=," %%A in (%temp%\column.csv) do ( set column01-30=%%A,%%B,%%C,%%D,%%E,%%F,%%G,%%H,%%I,%%J,%%K,%%L,%%M,%%N,^ %%O,%%P,%%Q,%%R,%%S,%%T,%%U,%%V,%%W,%%X,%%Y,%%Z,%%[,%%\,%%],%%^^ )
echo %column01-30% del %temp%\column.csv
Wannadoo script: Code: [Select]@echo off cls setlocal enabledelayedexpansion
:: Create csv file.. for /l %%a in (1,1,80) do ( set column=!column!Col.%%a, ) set column=!column:~0,-1! echo !column!>%temp%\column.csv
:: Extract leading 30 columns.. for /f "tokens=1-30* delims=," %%A in (%temp%\column.csv) do ( set column01-30=%%A thru' %%^^ )
echo %column01-30% del %temp%\column.csv
|