Solved Split files into 250 records each based on record count

October 31, 2012 at 00:24:53
Specs: Windows 7
Hi,

I am new to batch scripting and have a situation here. I have a huge csv file and I need to split the file into different files with 250 records each based on record count. How do I achieve this using a batch script?
Thanks!


See More: Split files into 250 records each based on record count

Report •


#1
October 31, 2012 at 11:31:15
You'll need to post some sample of both the raw (csv data) and what you want it to look like. Your post is far too vague, at least for my feeble understanding. You want vertical split, or horizontal? Record count? (Line number, something in the source data?)

Report •

#2
October 31, 2012 at 12:35:28
✔ Best Answer
reccommend testing
setlocal enabledelayedexpansion
set count1=0
set count2=1
for /f  "tokens=*" %%G IN (myfile.csv) DO (
set /a count1=(count1+1)
if count1=>250 set count1=0 && set /a count2=(count2+1)
echo %%G>>c:\filename%count2%.csv
)

:: mike


Report •

Related Solutions


Ask Question