Problem of Multiline in csv file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Problem of Multiline in csv file
# 1  
Old 07-29-2010
MySQL Problem of Multiline in csv file

Hi
I have csv file which has test as multiline in the one column. ex.

---------data.csv------------
Code:
Seqno,EmpID,EmpName,Dept
1,123,"Vipin 
Agrawal","IT
BUSINESS
OFFSHORE"
2,124,"Simon Bhai","IT"

The problem is name "Vipin Agrawal" has one new line character b/w name. same as Dept.
I want the result like -
Code:
1,123,"Vipin Agrawal","IT BUSINESS OFFSHORE"
2,124,"Simon Bhai","IT"

Thanks in advance!!!

Last edited by Scott; 07-29-2010 at 10:12 AM.. Reason: Added code tags
meetvipin
# 2  
Old 07-29-2010
Perl solution ,

Code:
use strict;
use warnings;

open FILE,"<file";

foreach ( <FILE> ) {
     if ( /^seqno/i ) { 
       print $_  ;
       next ;
     }
     if ( /^[0-9].+"$/ ) {
         print "\n$_" ;
     }
     else {
        chomp;
        print "$_ " ;
     }
}

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed multiline problem

I'm trying to replicate the sed output on p.108 of Sed&Awk,by Doughery & Robbins, 2nd edition. I'm on a Windows 10 Surface Pro, running Cygwin for 64-bit versions of Windows. Input text saved in text file called data_p108.txt: Consult Section 3.1 in the Owner and Operator Guide for a... (9 Replies)
Discussion started by: prooney
9 Replies

2. Shell Programming and Scripting

Save output of updated csv file as csv file itself, part 2

Hi, I have another problem. I want to sort another csv file by the first field. result.csv SourceFile,Airspeed,GPSLatitude,GPSLongitude,Temperature,Pressure,Altitude,Roll,Pitch,Yaw /home/intannf/foto5/2015_0313_090651_219.JPG,0.,-7.77223,110.37310,30.75,996.46,148.75,180.94,182.00,63.92 ... (2 Replies)
Discussion started by: refrain
2 Replies

3. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

4. Shell Programming and Scripting

How to create multiline csv cell through shell script?

Hi, I have a text like the one given below status="Observation 1" read1="Source rows not load" read2="Score drop" I want to create a csv and mail it out in such a way that all three lines will be in a single cell but as three lines. For ex Col C1 ... (3 Replies)
Discussion started by: prasperl
3 Replies

5. Shell Programming and Scripting

Format problem while converting text file to csv

Hi , I need a help in following scenario.I tried searching in google but couldn't able to find the exact answer. Sorry if i am re-posting already answered query. While i am trying to convert into log file into csv i couldn't able to get the format which i am looking for. I converted file... (4 Replies)
Discussion started by: varmas424
4 Replies

6. UNIX for Dummies Questions & Answers

Problem in creating CSV file

Hi guys, I am not experienced with Unix, so please dont mind if the question seem to be irrelevant. I have written a simple script, that connects DB & fetches few records from a table. I wanted to get those details as file in .CSV format via mail. -I stored the query o/p in a file. -I... (6 Replies)
Discussion started by: sumitburnwal88
6 Replies

7. UNIX for Advanced & Expert Users

Problem in converting password protected excel file to csv file in unix

I need to convert a password protected excel file which will be in UNIX server to a comma separated file. For this I need to open the excel file in UNIX box but the UNIX box doesn't prompt for password instead it is opened in an encrypted manner. I could manually ftp the excel file to local... (2 Replies)
Discussion started by: Devivish
2 Replies

8. Shell Programming and Scripting

Multiline replace problem

I have a data of the form 0.0117843924 0. 0. 0. 0. 0.011036017 0. 0. 0. 0. 0.0103351669 0. 0. 0. 0. 4839.41211 0. 0. 0. 0. 4532.08203 0. 0. 0. 0. I would like to insert a couple of blank lines before the 4839 line, every time it appears. The numbers in the... (2 Replies)
Discussion started by: mathis
2 Replies

9. Programming

Problem with csv file gen from C++

Hi Frnds, I have a problem with csv file gen. Here is the description: My code genereates a csv file as output in which a particular column("OUTPUT NUMBER")contains a string value fetched from db. Now the problem is when i open this csv file the OUTPUT NUMBER column misses the zero("0")... (10 Replies)
Discussion started by: electroon
10 Replies
Login or Register to Ask a Question