I'm not a expert in shell programming, so i've come here to take help from u gurus.
I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command.
I've a datatable csv of the below format -
--in file format
--our file format
As you can see above, each row of record is seperated by a line gap and also a row record is split into multiple lines. I've to make it in a format as shown below so that i can insert them into my informix db.
So i'm trying acheive two things here
1. Remove blank lines
2. Collide a data row splitted across multiple lines into one(by using the blank line as the end of a record)
Many Thanks!
Last edited by Franklin52; 03-08-2011 at 01:53 PM..
Reason: Please use code tags, thank you
Using the newline as the field separator, so $1 is line 1 and $2 is line 2
Using "," as the output field separator, so it adds an "," between the two when you print a,b
---------- Post updated at 12:16 PM ---------- Previous update was at 12:07 PM ----------
If you need an extra "," on the end you can just do print $1, $2, ""
It works partially good.
1. i've to implement this shell for hundreds of csv's, so i'm not quite sure on the number of lines for each record in these files. so print $1, $2 works well for two lines of record followed by a blank line. But this has to be dynamic.
2. It doesn't seem to add a extra delimiter to the end of each record, i.e before each blank line
When I 'vi' my test file I see some blank lines. However once I do :set list to display hidden characters, I see the empty lines literally like this:
^I$
How do I remove them? I cannot find a regex to match them. (3 Replies)
Hi,
I am facing a problem related to removing blank lines from a text document.
Input
Error 17-05-2011 11:01:15 VisualSVN Server 2.1 1001
The following information was included with the event:
line3
line4
Error 17-05-2011 11:00:25 VisualSVN Server 2.1 ... (13 Replies)
Hi,
Consider a file named "testfile"
The contents of file are as below
first line added for test
second line added for test
third line added for test
fourth line added for test
fifth line added for test (5 Replies)
I really hope someone can help me with this. I have several php files from a forum that I run, that now for some reason have blank lines after every line. Is there an easy way to make a script that does the following:
* If there are consecutive blank lines, delete all of them except one.
* If... (9 Replies)
I have joined 2 files. Join command worked fine.
but the result showing extra blank lines. I tried to remove blank spaces by using awk (-- -42 RS= ORS="\n\n" file.txt) and sed (sed '/^ *$/d' file.txt)commands but didn't remove any
Any suggestions plz:D
123 tab .......
......tab .......234... (3 Replies)
Hi gurus,
I have this file with blank lines in it.
How do i remove them in shell?
I tried these commands but not working:
sed '/^ *$/d'
or
sed '/^$/d'
Anybody has a better idea pls?
Also there are lines which starts with a single space, how do we remove the space in those lines?... (3 Replies)
Hi there,
I want to trim space between lines in unix.
I have a file named abc.txt with 2,00,000 lines.But useful are only a few. Please tell me how to delete the blank lines.:o (1 Reply)
What is the command to count lines in a files, but ignore blank lines and commented lines?
I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end.
Here is an example of what I would like my... (6 Replies)
¿How can i remove blank lines between all lines in a long text file?
Example
WrongFile.txt :
Line 1
Line 2
Line 3
CorrectFile.txt :
Line 1
Line 2
Line 3
Thanks in advance
:confused: (4 Replies)