Recently I've switched from windows to osx and I'm struggling to work out the best way to automate some tasks I used to use Windows Power Shell for.
In power shell I used to run a script to add & populate columns in a csv file
Import-Csv z:\myfile.csv | Select-Object @{Name='ACTION';Expression={''}},*,@{Name='COUNTRY';Expression={'UNITED KINGDOM'}} | Export-Csv z:\output.csv -NoTypeInformation
As you can see this adds 2 columns to the csv and populates Country with United Kingdom.
I also used to run this from a batch file which would create folders with the date & place the created files in before deleting the original file.
My question is what's the best / most efficient way to achieve this in osx?
I have looked and think it maybe awk, I have tried with automator but haven't had much success.
Thanks for any advice.
Assuming 1st line is header, if not remove heading 1!
sed '1!s/$/,,UNITED KINGDOM/' z:\myfile.csv > z:\output.csv
it add to end of each line, except 1st, the trailing ,,UNITED KINGDOM
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.