![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RSS feeds to Email | Mukka | Shell Programming and Scripting | 0 | 03-18-2008 07:27 PM |
| RSS Feeds of Threads | craigp84 | Post Here to Contact Site Administrators and Moderators | 11 | 12-13-2007 09:33 AM |
| Spurious line feeds | ajcannon | Shell Programming and Scripting | 2 | 10-29-2007 04:24 AM |
| Remove line feeds | vsk | Shell Programming and Scripting | 8 | 06-16-2005 09:28 AM |
| carriage return/line feeds | pitstop | Shell Programming and Scripting | 4 | 11-24-2003 12:47 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
line feeds in csv
i have csv file with three comma separated columns i/p file First_Name, Address, Last_Name XXX, "456 New albany \n newyork, Unitedstates \n 45322-33", YYY\n ZZZ, "654 rifle park \n toronto, canada \n 43L-w3b", RRR\n is there any way i can remove \n (newline) from the second column between the two double quotes"..." |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
will this do?
Code:
sed 's/\\n//g' csvFile |
|
#3
|
|||
|
|||
|
i tried using sed commands !
thanks vgersh99
I tired that ! but it didn't work . all it does is removes all the \n from the csvfile. ( i.e ) all the data will be in one single line . |
|
#4
|
||||
|
||||
|
Just change the pattern that vgersh99 said try something like
sed 's/\\n/\"^["]*\"' \" for checking starting quotes ^["] for checking anything other than " (inside [] no metachr except '-' means anything so no need for \") and lastly \\n for newline. g as suggested by vgersh stands for globaly and so should not be used here. I haven't run this (away from any Linux box) so in case of problem just fiddle with above pattern & if u still have problem plz. do tell me. Last edited by Rakesh Ranjan; 09-01-2005 at 05:10 AM. |
|
#5
|
||||
|
||||
|
Quote:
Quote:
Code:
First_Name, Address, Last_Name XXX, "456 New albany newyork, Unitedstates 45322-33", YYY ZZZ, "654 rifle park toronto, canada 43L-w3b", RRR |
|
#6
|
|||
|
|||
|
ranjan
thanks man !
I tried ur suggestion, it didn't workout---i got this error msg! sed: command garbled: s/\\n/\"^["]*\" click on this link, there was a similar problem in this site , they had the solution too but not clear enough for me to solve my problem.. Remove Carriage returns between strings in a field I didn't understand how they are calling the file, how the loop exactly workings Please lookat the solution,please suggest me on this . thanks Gowrish |
|
#7
|
||||
|
||||
|
Quote:
Code:
s/regular expression/replacement/flags
Substitute the replacement string for
instances of the regular expression in the
pattern space. Any character other than
backslash or newline can be used instead of a
slash to delimit the RE and the replacement.
Within the RE and the replacement, the RE del-
imiter itself can be used as a literal charac-
ter if it is preceded by a backslash.
An ampersand (&) appearing in the replacement
will be replaced by the string matching the
RE. The special meaning of & in this context
can be suppressed by preceding it by
backslash. The characters \n, where n is a
digit, will be replaced by the text matched by
the corresponding backreference expression.
For each backslash (\) encountered in scanning
replacement from beginning to end, the follow-
ing character loses its special meaning (if
any). It is unspecified what special meaning
is given to any character other than &, \ or
digits.
|
||||
| Google The UNIX and Linux Forums |