file formating in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting file formating in Perl
# 1  
Old 04-28-2009
Data file formating in Perl

Hi,
I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement ..
My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need to add some text and create a output file for this .
Input records fields: (name,age,CUID,ZIP)

jim,23,49089,56098
sue,45,,870089
mike,52,89387,89076

output file:
jim 23 49089 56098
sue 45 NO 870089
mike 52 89387 89076


It checking each fields value , the CUID field values for sue is blank.so it add "NO" then generates the output with some fixed filed size length.

Please help me regarding this .


Thanks in advance .
# 2  
Old 04-28-2009
If you are intending to use perl, you could probably use the split() function to split the lines on the commas and check each field for valid data, if none is there, add "NO" or whatever. I say "probably" because you have not describe the situation very well.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with ... Formating the file using awk

I have a file like below position1 0 7802 7802 0 client1 - - position1 8 8032 8032 0 client1 ... (7 Replies)
Discussion started by: manas_ranjan
7 Replies

2. Shell Programming and Scripting

File formating

I need to create a fixed width file based on the column lengths. lets assume I have six(this may be dynamic) fields each are of different length column1=6 #size of the column column2=3 column3=2 column4=3 column5=4 column6=5 I tried below code snippet but it is not working echo... (4 Replies)
Discussion started by: gvkumar25
4 Replies

3. UNIX for Beginners Questions & Answers

File formating help

Hi all, I am having the file below I need that as below Thanks, Arun (12 Replies)
Discussion started by: arunkumar_mca
12 Replies

4. UNIX for Beginners Questions & Answers

File formating with lines

Hi All, Need to modify a file basically join the extra line to one I am having a file like below And would like to make it as below . (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

5. Programming

[Perl] Different printf formating for different print options

Hi, Struggling with single quotes, double quotes, etc. I want to print a header line, followed by lines with actual values, based on a print option. In real life it is going to be something like 15 print options and 50 values. Output will be 1 header and several value lines. In this example... (5 Replies)
Discussion started by: ejdv
5 Replies

6. Shell Programming and Scripting

Formating of query variable in perl

Hi , I am facing error in perl when I assign a below query in a varibale $query because of new line charchters $query= SELECT XYZ , ABC , c2 , c3 , c4 FROM t1 how can i get rid of new line charchters with out changing the... (2 Replies)
Discussion started by: gvk25
2 Replies

7. Shell Programming and Scripting

Help in formating a txt file

Pls help in formatting a txt file using shell scripting Input file format: Name priya 2010-09-21 10:43:49 TEXT ID 1 hi TEXT ID 2 how TEXT ID 3 r TEXT ID 4 u Output required: name priya hi how r u (4 Replies)
Discussion started by: bha148
4 Replies

8. Shell Programming and Scripting

File formating question.

Hi, I have a file with only data 1 row: AA#?BB#?CC#?DD Assume '#?' is the delimiter, i want the output in another file to be: AA BB CC DD Pls let me know if this is possible by sed ? Thanks in advance. (3 Replies)
Discussion started by: smc3
3 Replies

9. Shell Programming and Scripting

Date Formating in Perl

Hi All, Can anybody tell me why is there a "0" in my output of $date_today ? #!/usr/local/bin/perl $date_today = system "date '+%y%m%d'"; print "$date_today\n"; Output: $ perl test4 080908 0 (3 Replies)
Discussion started by: Raynon
3 Replies

10. Shell Programming and Scripting

formating array file output using perl

Hello, I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example: @array= 1..14; Needs to be output to the file like so: 1 ... (4 Replies)
Discussion started by: seismic_willy
4 Replies
Login or Register to Ask a Question