LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Splitting up a csv file into lines (https://www.linuxquestions.org/questions/linux-newbie-8/splitting-up-a-csv-file-into-lines-4175539409/)

pulsar1279 04-11-2015 12:53 PM

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..

pan64 04-11-2015 12:56 PM

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)

pulsar1279 04-11-2015 01:00 PM

will get a bit up in a minute..

pulsar1279 04-11-2015 01:05 PM

,(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

allend 04-11-2015 01:28 PM

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.

pulsar1279 04-11-2015 03:29 PM

Thanks, I'll give it a go


All times are GMT -5. The time now is 11:40 AM.