to insert row of columns for conents in csv file
Moderator: DosItHelp
to insert row of columns for conents in csv file
i have csv file having the contents, now i have to insert column name for this contents i.e i need to insert 1st row on top of the contents present in the csv file.
please let me know how this can achived..
At present csv file will be like this:
dany.lessard dany.lessard@cgi.com Dany Lessard Dany Lessard 105960 A
i want this to be look like as below:
Loginid emailid FN LN FullName EMPID Status
dany.lessard dany.lessard@cgi.com Dany Lessard Dany Lessard 105960 A
Thank you...
Regards,
Santosh
please let me know how this can achived..
At present csv file will be like this:
dany.lessard dany.lessard@cgi.com Dany Lessard Dany Lessard 105960 A
i want this to be look like as below:
Loginid emailid FN LN FullName EMPID Status
dany.lessard dany.lessard@cgi.com Dany Lessard Dany Lessard 105960 A
Thank you...
Regards,
Santosh
Re: to insert row of columns for conents in csv file
You need to rewrite the entire file.
This renames file.csv and then creates a new file.csv with the header, and then appends the original file into the new file.
This renames file.csv and then creates a new file.csv with the header, and then appends the original file into the new file.
Code: Select all
@echo off
ren file.csv file.csv.old
echo Loginid emailid FN LN FullName EMPID Status>file.csv
type file.csv.old >> file.csv
del file.csv.old
Re: to insert row of columns for conents in csv file
Do you enjoy getting spam email. Not a good idea to make your user name for the forums as your email address. Should probably not post any valid email addresses for example data either.
Re: to insert row of columns for conents in csv file
Hi,
Thnks for the reply. below code is just creating the column names in new csv file(without the contents).also its create Loginid emailid FN LN FullName EMPID Status headers in single column
below is the code i have tested.
@echo off
ren file.csv fileold.csv
echo Loginid emailid FN LN FullName EMPID Status>file.csv
type fileold.csv >> file.csv
del fileold.csv
fileold.csv-having only contents without column headers.
Please let me know if i am missing something..
Thank you
Thnks for the reply. below code is just creating the column names in new csv file(without the contents).also its create Loginid emailid FN LN FullName EMPID Status headers in single column
below is the code i have tested.
@echo off
ren file.csv fileold.csv
echo Loginid emailid FN LN FullName EMPID Status>file.csv
type fileold.csv >> file.csv
del fileold.csv
fileold.csv-having only contents without column headers.
Please let me know if i am missing something..
Thank you
Re: to insert row of columns for conents in csv file
santuraj12@gmail.com wrote:
Thnks for the reply. below code is just creating the column names in new csv file(without the contents).also its create Loginid emailid FN LN FullName EMPID Status headers in single column
fileold.csv-having only contents without column headers.
The code works here. You start with a file called file.csv in the same folder as the batch file, and then launch the batch file.
Ensure that file.csv is not open in another program at the time.
Re: to insert row of columns for conents in csv file
Hi,
whether i need to have only the data in file.csv?
whether i need to have only the data in file.csv?
Re: to insert row of columns for conents in csv file
I don't understand your question.
The code will put a header on the file, that's all it does.
The code will put a header on the file, that's all it does.
Re: to insert row of columns for conents in csv file
hi,
Thnks for your inputs, i was able to get what i had expected. below is the code i had written
1.csv -> file having only header
2.csv->file having contents/data
batch file code:
type 2.csv >> 1.csv
Thnks for your inputs, i was able to get what i had expected. below is the code i had written
1.csv -> file having only header
2.csv->file having contents/data
batch file code:
type 2.csv >> 1.csv
Re: to insert row of columns for conents in csv file
Hi,
need your inputs once again
now i am having the requirments to split the contents of csv file. ex: if csv file is having 70K rows i need to split that in to 2 files having 35k in each.
how we can implement this through batch file code?
Thank you
need your inputs once again
now i am having the requirments to split the contents of csv file. ex: if csv file is having 70K rows i need to split that in to 2 files having 35k in each.
how we can implement this through batch file code?
Thank you
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: to insert row of columns for conents in csv file
santuraj12@gmail.com wrote:Hi,
need your inputs once again
now i am having the requirments to split the contents of csv file. ex: if csv file is having 70K rows i need to split that in to 2 files having 35k in each.
how we can implement this through batch file code?
Thank you
Does the csv file have to split regardless of size, or only after the file gets to a certain size?
Re: to insert row of columns for conents in csv file
This will give you lines 1 to 35000 in newfile1.csv
and lines 35001 to the end in file newfile2.csv
This uses a helper batch file called `findrepl.bat` - download from: https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat
Place `findrepl.bat` in the same folder as the batch file or on the path.
and lines 35001 to the end in file newfile2.csv
Code: Select all
findrepl /o:1:35000 <file.csv >newfile1.csv
findrepl /o:35001 <file.csv >newfile2.csv
This uses a helper batch file called `findrepl.bat` - download from: https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat
Place `findrepl.bat` in the same folder as the batch file or on the path.