05-19-2014
Replace Control M (^M) character with new line
Hi All,
We are getting an external file in abc.csv format. When opened in excel spread sheet, it is opening alright. But when opened in notepad, I see the contents in a single line.
Ftp'd the file in binary mode to AIX UNIX host. When opened, I see Control M (^M) characters in place of New Line characters.
I did the following:
$ wc -l abc.txt
0 abc.txt
$ sed 's/^M//g' abc.txt > xyz.txt
$ sed 's/^M$//' abc.txt > xyz.txt
I'm unable to replace the ^M character with new line. Can you kindly help me with the solution?
Thanks in advance.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello Sed Experts,
I have got a file which contain entries as below
pmNoOfSwDownHsCong,
pmUlUpswitchAttemptHigh,
pmUlUpswitchAttemptLow,
pmUlUpswitchSuccessHigh,
pmUlUpswitchSuccessLow,
pmUpswitchFachHsAttempt, ... (6 Replies)
Discussion started by: Mohammed
6 Replies
2. Shell Programming and Scripting
sample I/p:
S12J LLL
H77K PPP
J25O LOP
I73S lOP
K99O PLO
Required O/p:
S12J LLL H77K PPP J25O LOP I73S lOP K99O PLO
how to replace a new line character with space using sed command only
Cheers,
Chan (2 Replies)
Discussion started by: chan
2 Replies
3. Shell Programming and Scripting
Hello all... please help with the following.
I am parsing the following type of file...
W001;
W003;
W025;W044;
W030;
W022;W024;W099;W098;
Would like to make it look like this...
W001
W003
W025
W044
W030
W022
W024
W099
W098 (8 Replies)
Discussion started by: djsal
8 Replies
4. Shell Programming and Scripting
<reward_data><date><datetime>071308000804</datetime></date>
I want the above data to be displayed as
<reward_data>
<date>
<datetime>071308000804</datetime>
</date>
How can i accomplish this.
I tried the below
tr "><" ">\n" < filename (4 Replies)
Discussion started by: borncrazy
4 Replies
5. Shell Programming and Scripting
I have unix text file which has the following data
aadjdfad;fa;fjjd;lakd;lkaslkd;k;k;lk;k;lk;l;lk;lkj;lj;lkj;k;lkj;lj;lkj;lkj;lkj;j
sdkadk;adlf;lajf;akdjf;lkdjf;lkadjf;lkajsd;lfkj;lkj;lkj;lk;lk;lk;lk;k;lkj;k;lkm... (2 Replies)
Discussion started by: Raju Datla
2 Replies
6. UNIX for Dummies Questions & Answers
Greetings,
Using vi, how can I change the following text:
-I/myviews/nexus_7400rel/vobs/nexus/platforms/97400/include -I/myviews/nexus_7400rel/vobs/nexus/modules/i2c/7400/include -I/myviews/nexus_7400rel/vobs/nexus/modules/surface/7400/include
Into this:... (4 Replies)
Discussion started by: omega949
4 Replies
7. Shell Programming and Scripting
Need to replace any control character in the string in perl
---------- Post updated at 04:22 PM ---------- Previous update was at 03:50 PM ----------
Any help !!!
Thanks in advance (2 Replies)
Discussion started by: hansini
2 Replies
8. Shell Programming and Scripting
Hi all.
I wonder if this possible.... any help advice is very much appreciated..
I n a shell script I create a latex file that looks like this
\documentclass{article}
\usepackage{graphics}
\begin{document}
\begin{figure}
\begin{center}
\begin{tabular}{cc}
... (10 Replies)
Discussion started by: malandisa
10 Replies
9. Solaris
I get a file which has all its content in a single row.
The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file.
I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies
10. Shell Programming and Scripting
I have a file which has n number of lines, i want to replace 3rd line position 3-5 to some text.
111111111111111111
222222222222222222
333333333333333333
444444444444444444
expected output
111111111111111111
222222222222222222
33abc3333333333333
444444444444444444
it is... (7 Replies)
Discussion started by: greenworld123
7 Replies
LEARN ABOUT DEBIAN
text::csv::encoded::coder::encodeguess
Text::CSV::Encoded::Coder::EncodeGuess(3pm) User Contributed Perl Documentation Text::CSV::Encoded::Coder::EncodeGuess(3pm)
NAME
Text::CSV::Encoded::Coder::EncodeGuess - Text::CSV::Encoded coder class using Encode::Guess
SYNOPSIS
use Text::CSV::Encoded coder_class => 'Text::CSV::Encoded::Coder::EncodeGuess';
use Spreadsheet::ParseExcel;
my $csv = Text::CSV::Encoded->new();
$csv->encoding( ['ucs2', 'ascii'] ); # guessing ucs2 or ascii?
$csv->encoding_to_combine('shiftjis');
my $excel = Spreadsheet::ParseExcel::Workbook->Parse( $file );
my $sheet = $excel->{Worksheet}->[0];
for my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) {
my @fields;
for my $col ( $sheet->{MinCol} .. $sheet->{MaxCol} ) {
my $cell = $sheet->{Cells}[$row][$col];
push @fields, $cell->{Val};
}
$csv->combine( @fields ) or die;
print $csv->string, "
";
}
DESCRIPTION
This module is inherited from Text::CSV::Encoded::Coder::Encode.
USE
Except for 2 attributes, same as Text::CSV::Encoded::Coder::Encode.
encoding_in
$csv = $csv->encoding_in( $encoding_list_ref );
The accessor to an encoding for pre-parsing CSV strings. If no encoding is given, returns current $encoding, otherwise the object itself.
$encoding_list_ref = $csv->encoding_in()
When you pass a list reference, it might guess the encoding from the given list.
$csv->encoding_in( ['shiftjis', 'euc-jp', 'iso-20022-jp'] );
If it cannot guess the encoding, the first encoding of the list is used.
encoding
$csv = $csv->encoding( $encoding_list_ref );
$encoding_list_ref = $csv->encoding();
You can pass a list reference to this attribute only:
* For list data consumed by combine().
* For list reference returned by getline().
In other word, in "combine" and "print", it might guess an encoding for the passing list data. If it cannot guess the encoding, the first
encoding of the list is used.
SEE ALSO
Encode, Encode::Guess
AUTHOR
Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
COPYRIGHT AND LICENSE
Copyright 2008-2010 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2010-04-26 Text::CSV::Encoded::Coder::EncodeGuess(3pm)