473,378 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Is there an awk or sed to remove invalid rows ?

I have a file with rows with 10 columns, separated by 9 “|” (pipe) separators.

However, every now and again, I am getting spurious rows appearing with no separators at all, or other rows appearing with fewer than the 9 separators.

There is no way for me to prevent them from appearing from within the application,

So, my question is, is there an awk command, or, preferably, a sed command, which anyone can provide which will strip out these non-standard rows ??

Many thanks in advance.
Jan 4 '11 #1
1 2082
Mariostg
332 100+
You could use the NF (number of field) variable of awk.
Expand|Select|Wrap|Line Numbers
  1. FS="|"
  2. if (NF == 10) {
  3.   Do your stuff;
  4. } else  {
  5.   Do something else;
  6.  
  7.  
Jan 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Damien Cobbs | last post by:
Is there a way to remove duplicate rows from a table that does not have a primary key leaving one copy of the row without comparing each column to each other as suggested by the code example below:...
0
by: alcesteatxmissiondot | last post by:
I have a table with a couple of TEXT columns. In one of them, there are characters that aren't supported by the application and don't seem to be able to display in the Query Analyzer either. I...
3
by: kie | last post by:
url explaining what i' trying to do @ http://www.kieran.f2s.com/remove_all_rows_all_tables.htm hi, i want to create a function removing all rows from 3 tables. the tables were created using...
3
by: Diego Rey | last post by:
Hi everyone. How can I get the unique row from a table which contains multiple rows that have exactly the same values. example: create table test ( c1 as smallint, c2 as smallint, c3 as...
1
by: TaeHo Yoo | last post by:
I have a table that has more than 1 milion rows so practically it is impossible to remove all duplicate rows by hand. Could you help me to remove those duplicate rows at all? This table doesn't...
3
by: Agnes | last post by:
I need to Load 4thousand record into a datagrid for the user to choose. After the user click the row, I will save it. Now, How can I remove the uncheck row. Dim myDelRowArray() As DataRow =...
5
by: dale.zjc | last post by:
I've got the following table data: 11652 5.99 11652 0.14 12996 5.03 12996 0.12 12996 7.00 And I need to write a query to return only rows 2 and 4, since the remaining rows have duplicate...
7
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
4
by: sudhaMurugesan | last post by:
Hi all, I am importing data from excel sheet. i get the data in a datatable. when there are empty rows in excel i am getting empty rows in datatable also. how to remove empty rows? help me...
1
by: premMS143 | last post by:
Hi 1 & all, Using VB, How to remove blank rows in a Excel worksheet? For example, I'm having a Excel sheet containing 900 rows data, in which there are blank rows inserted in between. Manually...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.