Populating a new column with current date in a csv file
Moderator: DosItHelp
-
- Posts: 3
- Joined: 09 Feb 2015 10:28
Populating a new column with current date in a csv file
I have a csv file that currently has 3 columns and over 7000 rows. I need to create populate a 4th column with the current date (ex: 02/09/2015) for all of the rows. Any help is appreciated.
Re: Populating a new column with current date in a csv file
assuming your date variable is in this format.
You can use this.
There are ways to make the date regional independent should it be in a different format.
Code: Select all
H:\>echo %date%
Mon 02/09/2015
You can use this.
Code: Select all
@echo off
set tdate=%date:~4%
FOR /F "delims=" %%G IN (myfile.csv) DO >>newfile.csv echo %%G,%tdate%
There are ways to make the date regional independent should it be in a different format.
-
- Posts: 3
- Joined: 09 Feb 2015 10:28
Re: Populating a new column with current date in a csv file
This worked...thank you. I am very new to scripts and now need to do this for a 2 column csv. Is it the 4% that tells it to put it in the 4th column?
-
- Posts: 3
- Joined: 09 Feb 2015 10:28
Re: Populating a new column with current date in a csv file
Disregard my 2nd reply...it works great! Thank you.