How to check record delimiter of a file ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check record delimiter of a file ?
# 1  
Old 08-16-2016
How to check record delimiter of a file ?

My requirment is for every record of a particular file I've to check for a record delimeter (e.g. "\n") and if any row doesn't have "\n" then report it in error file .

Please suggest me to go through this.
# 2  
Old 08-16-2016
Hello manab86,

I have a few to questions pose in response first:-
  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • How do you know if you get a double row, e.g. is there a specific length or number of columns?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.
# 3  
Old 08-16-2016
On top of what rbatte1 is asking, in your request, what's the difference between a "record" and a "row" (=line)?
# 4  
Old 08-16-2016
Quote:
Originally Posted by manab86
My requirment is for every record of a particular file I've to check for a record delimeter (e.g. "\n") and if any row doesn't have "\n" then report it in error file .
Basically your file has a structure like this:

Code:
<record><delimiter><record><delimiter>.....

If some delimiter would be missing it would be:

Code:
<record><record><delimiter>.....

that is, two records without a delimiter between them. You can create a program to check for that BUT ONLY if you have a very rigid definition for what a "record" constitutes and provided that you can implement that definition in code.

In general you need to be able to find out where one record ends and the next begins. But with such a mechanism in place you do not need any delimiter (as a separate character) at all because the records are already "delimited" by their beginning/ending markers, whatever these may be.

I hope this helps.

bakunin
# 5  
Old 08-16-2016
Also, is this to be done only with unix commands/utilities or can you write a program to do it? If so, what commands or utilities? Or what programming languages?

Last edited by rbatte1; 08-17-2016 at 06:57 AM.. Reason: Spelling
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to split large file with different record delimiter?

Hi, I have received a file which is 20 GB. We would like to split the file into 4 equal parts and process it to avoid memory issues. If the record delimiter is unix new line, I could use split command either with option l or b. The problem is that the line terminator is |##| How to use... (5 Replies)
Discussion started by: Ravi.K
5 Replies

2. UNIX for Dummies Questions & Answers

How to check tar file record?

Hi Guys, I had some file which that I made tar their, now I need to know tar file record then how to find it. (5 Replies)
Discussion started by: aaditya321
5 Replies

3. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

4. Shell Programming and Scripting

Perl Code to change file delimiter (passed as argument) to bar delimiter

Hi, Extremely new to Perl scripting, but need a quick fix without using TEXT::CSV I need to read in a file, pass any delimiter as an argument, and convert it to bar delimited on the output. In addition, enclose fields within double quotes in case of any embedded delimiters. Any help would... (2 Replies)
Discussion started by: JPB1977
2 Replies

5. Programming

Check record

moved (0 Replies)
Discussion started by: ust3
0 Replies

6. Shell Programming and Scripting

Shell script to put delimiter for a no delimiter variable length text file

Hi, I have a No Delimiter variable length text file with following schema - Column Name Data length Firstname 5 Lastname 5 age 3 phoneno1 10 phoneno2 10 phoneno3 10 sample data - ... (16 Replies)
Discussion started by: Gaurav Martha
16 Replies

7. Shell Programming and Scripting

split record based on delimiter

Hi, My inputfile contains field separaer is ^. 12^inms^ 13^fakdks^ssk^s3 23^avsd^ 13^fakdks^ssk^a4 I wanted to print only 2 delimiter occurence i.e 12^inms^ 23^avsd^ (4 Replies)
Discussion started by: Jairaj
4 Replies

8. Shell Programming and Scripting

Check length of record

Hi, I have a problem, please help me, I have a flat file like this: P00000000088888888999999999 0000999903 000000000000000000 P00000000077777777000000000 0000999903 000000000000000000 P00000000044444444333333333 0000999903 00000000000000000079875 P00000000066666666111111111 0000999903 ... (5 Replies)
Discussion started by: DebianJ
5 Replies

9. Shell Programming and Scripting

Pivot variable record length file and change delimiter

Hi experts. I got a file (500mb max) and need to pivot it (loading into ORCL) and change BLANK delimiter to PIPE |. Sometimes there are multipel BLANKS (as a particular value may be BLANK, or simply two BLANKS instead of one BLANK). thanks for your input! Cheers, Layout... (3 Replies)
Discussion started by: thomasr
3 Replies
Login or Register to Ask a Question