Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 27th, 2008, 6:53 AM   #1
Celsoft
Newbie
 
Join Date: Aug 2008
Posts: 3
Rep Power: 0 Celsoft is on a distinguished road
Question Remove commas from text fields in .csv

This must have been done a million times but I can't seem to find the solution

I have a "normal" comma-separated file (.csv) with some text fields in double-quotes. These fields MAY contain a comma, which should be changed to a space.

I want to use sed or awk (or gawk) to zap the unwanted commas, leaving the legit delimiting commas intact.

Any help appreciated ... TA
Celsoft is offline   Reply With Quote
Old Aug 28th, 2008, 11:27 AM   #2
Celsoft
Newbie
 
Join Date: Aug 2008
Posts: 3
Rep Power: 0 Celsoft is on a distinguished road
Re: Remove commas from text fields in .csv

Just to add - Problem solved (with the help of some genii !) The following worked for me:

gawk -F\" -v OFS=\" -f awkscr.txt Infile > Outfile

with awkscr.txt containing:
{ for (i=2; i<=NF; i+=2) { gsub(","," ",$i) }; print }
Celsoft is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting spaces between formatted text fields Fall Back Son Java 7 Feb 12th, 2008 9:40 PM
text files auto imported into fields Micskill HTML / XHTML / CSS 1 Nov 26th, 2007 10:24 PM
using Text fields in SWT elford Java 4 Dec 27th, 2005 1:38 PM
Resizing fields to match text Arla C# 3 Aug 4th, 2005 2:56 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC