I have a csv extract that have repeated header columns on it. The header shows up on every group data. Is there a way to just delete all other instance of that header and just retain the one on the top.
When I try to use findstr it will delete all of my columns.
deleting multiple column headers in csv file
Moderator: DosItHelp
-
- Posts: 82
- Joined: 30 Dec 2013 10:16
- Location: United States by the big waterfall
Re: deleting multiple column headers in csv file
Post your code.
-
- Posts: 5
- Joined: 28 Jan 2016 09:06
Re: deleting multiple column headers in csv file
This is the code that I used:
This is my header format Student Group, Group Name. These headers repeat itself on every Student Group on the csv file. When I try to used the code above. It will delete all the header line entry. What I am trying to do is retain the first header line and all duplicate occurrence will be deleted.
Code: Select all
findstr /v /c:"Student Group" %p%Student.csv > %p%Student_%t%.csv
This is my header format Student Group, Group Name. These headers repeat itself on every Student Group on the csv file. When I try to used the code above. It will delete all the header line entry. What I am trying to do is retain the first header line and all duplicate occurrence will be deleted.
Last edited by Squashman on 28 Jan 2016 11:52, edited 1 time in total.
Reason: MOD EDIT: Please use code tags
Reason: MOD EDIT: Please use code tags
Re: deleting multiple column headers in csv file
If your header line is shorter than 1024 bytes and does not have any special characters in it, you can use this.
Code: Select all
set /p header=<%p%Student.csv
echo %header% > %p%Student_%t%.csv
findstr /v /c:"Student Group" %p%Student.csv >> %p%Student_%t%.csv
-
- Posts: 5
- Joined: 28 Jan 2016 09:06
Re: deleting multiple column headers in csv file
Squashman wrote:If your header line is shorter than 1024 bytes and does not have any special characters in it, you can use this.Code: Select all
set /p header=<%p%Student.csv
echo %header% > %p%Student_%t%.csv
findstr /v /c:"Student Group" %p%Student.csv >> %p%Student_%t%.csv
This code works! Thank you so much!