LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 08-08-2012, 12:31 AM   #1
ingram87
LQ Newbie
 
Registered: Aug 2011
Posts: 9

Rep: Reputation: Disabled
How to make a column in a CSV file lowercase from terminal?


How do you make an entire column (and only a single column) from a CSV file lowercase from the command line? I can do this easily in Writer, but I have a large number of CSV's and it would take to long to do it manually. Here is an example of my CSV file:
Code:
1,Roger,TALL,34,
2,Janice,SHORT,22,
3,Matt,TALL,18,
I would like to make the 3rd column (tall,short) lowercase.
Any help would be appreciated!
 
Old 08-08-2012, 12:39 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello,

You can do that with awk. I'm still in the learning process so others might provide another (shorter solution) but this one works. I saved your example in test.csv and redirected output in testout.csv.
Code:
awk -F',' '{ print $1","$2","tolower($3)","$4; }' < test.csv > testout.csv
Hope it helps.

Kind regards,

Eric
 
Old 08-08-2012, 01:01 AM   #3
ingram87
LQ Newbie
 
Registered: Aug 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by EricTRA View Post
Hello,

You can do that with awk. I'm still in the learning process so others might provide another (shorter solution) but this one works. I saved your example in test.csv and redirected output in testout.csv.
Code:
awk -F',' '{ print $1","$2","tolower($3)","$4; }' < test.csv > testout.csv
Hope it helps.

Kind regards,

Eric
Thanks, that's exactly what I was looking for
 
Old 08-08-2012, 01:09 AM   #4
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

Glad it helps. Thanks for marking the thread as solved. Have fun with Linux.

Kind regards,

Eric
 
  


Reply

Tags
csv


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] validating mandatory column value in csv file using script sukhdip Linux - Newbie 2 01-31-2012 02:45 AM
How to read CSV data and compare the column values and then write them in new file VijayaRaghavanLakshman Linux - Newbie 9 01-26-2012 09:02 PM
awk - rearrange column data in csv file to match columns wolverene13 Programming 9 12-21-2011 04:55 AM
How to redirect the output to a different column in .csv file Sayan Acharjee Linux - General 2 04-25-2011 11:43 AM
Rearrange the column in CSV file.. govi1234 Linux - Newbie 9 08-27-2010 07:15 PM


All times are GMT -5. The time now is 03:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration