LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-11-2015, 01:53 PM   #1
pulsar1279
LQ Newbie
 
Registered: Apr 2015
Posts: 5

Rep: Reputation: Disabled
Splitting up a csv file into lines


Hi all,
I have a large csv file which linux sees large amounts of it as one line. I've been trying to break it up with sed, from..
(name,address,etc),(name,address,etc),(name,address,etc) into

(name,address,etc)
(name,address,etc)
(name,address,etc)

each on their own line.. can this be done with sed? And if not what other commands can I use to do it..

Thanks
pulsar..
 
Old 04-11-2015, 01:56 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,475

Rep: Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424
would be nice to see the format of the original file, otherwise hard to say anything (I mean please post a few records of the original file)
 
Old 04-11-2015, 02:00 PM   #3
pulsar1279
LQ Newbie
 
Registered: Apr 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
will get a bit up in a minute..
 
Old 04-11-2015, 02:05 PM   #4
pulsar1279
LQ Newbie
 
Registered: Apr 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
,(11,'acfly','80536195','Ted lander','tshep0001@nowhere.com',1,0,'','','','','','',0,'http://www.bootk
it.com/usericons/acfly.jpg','',0,'',0,0,0,0,0,0,0,'','0','','','',-1,''),(12,'achapman','d8b2212c','Alan Chapman','achapman5@home.com',1,0,'','','',''
,'','',0,'http://www.bootkit.com/usericons/achapman.jpg','',0,'',0,0,0,0,0,0,0,'','0','','','',-1,''),(13,'acidsky','094d114b','AcidSky','a

each record is bracketed ( ) and I can get out the extra 00.0.0.0.0. etc - don't know how to break into lines
 
Old 04-11-2015, 02:28 PM   #5
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,461

Rep: Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368
The actual record separator is ),( which you want to convert to a standard line ending. In Linux this is just LF (\n) while in the Windows world it is CRLF (\r\n).
Try, for Linux
Code:
sed 's/),(/\n/g' <inputfile>
or, for Windows
Code:
sed 's/),(/\r\n/g' <inputfile>
Note, this will likely leave extraneous parantheses characters at the start and end of the file.

Last edited by allend; 04-11-2015 at 02:31 PM.
 
Old 04-11-2015, 04:29 PM   #6
pulsar1279
LQ Newbie
 
Registered: Apr 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks, I'll give it a go
 
  


Reply


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
Removing multiple lines from cell data in a .csv file AZTiger98 Linux - Newbie 14 04-06-2015 10:35 AM
[SOLVED] splitting csv into array with IFS sudowtf Linux - General 2 12-21-2014 11:42 AM
Consolidate several lines of a CSV file with firewall rules, in order to parse them e starriol Programming 2 10-12-2013 08:13 PM
[SOLVED] A challenging script - Replace field of CSV file based on another CSV file arbex5 Programming 11 06-12-2013 07:56 AM
Splitting Text lines? 0aniel Programming 9 11-30-2005 04:08 AM


All times are GMT -5. The time now is 01:04 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration