خرید بک لینک

I have a 100 line csv file, with 5 values per line. I am looking for a way to export each line to its own csv file adding a 2 line header to each. I have used the split command seen elsewhere to create multiple files, but have not found a way to append the header. Also, if possible, can one of the variables be pulled to the file name? Thank you.

Example below.

Orig
Jack,7,blue,001
Jane,6,red,002
Mike,4,orange,003

result
List001.csv
first,number,favorite
Name,age,color
Jack,7,blue

List002.csv
first,number,favorite
Name,age,color
Jane,6,red

This is the file I am using:

@echo off setLocal EnableDelayedExpansion

set limit=1 set file=userlist.csv set lineCounter=1 set filenameCounter=101

set name=Usertable set extension=csv for %%a in (%file%) do ( set "name=%%~na" set "extension=%%~xa" )

for /f "tokens=*" %%a in (%file%) do ( set splitFile=%name%%filenameCounter%%extension% if %lineCounter% gtr %limit% ( set /a filenameCounter=%filenameCounter% + 1 set lineCounter=1 echo Created %splitFile%. ) echo %%a>> %splitFile%

set /a lineCounter=%lineCounter% + 1

)

برچسب: نویسنده: استخدام کار تاريخ: شنبه 14 فروردين 1395 ساعت: 1:02

صفحه بندی