Read flat file upto certain number of columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read flat file upto certain number of columns
# 1  
Old 11-07-2011
Read flat file upto certain number of columns

Hello Guys

Please help me with the below issue

I want to read a flat file source upto certain number of columns
Say my flat file has 30 columns but I want to read upto 25 columns only

How come the above issue can be addressed?

Thanks a lot!!!!
# 2  
Old 11-07-2011
I have given space as a delimiter here ..
Code:
$ cut -d' ' -f1-25 < infile


Last edited by jayan_jay; 11-07-2011 at 05:48 AM.. Reason: code change ..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get line number in flat file

Hi, Is there a way to find out the line number from where the data starts? like if the data contains column header, irrespective of the text in the column header we should get the line number from which contains the column header. I am sorry if I haven't explained the problem clearly. ... (8 Replies)
Discussion started by: kedar_laveti
8 Replies

2. Shell Programming and Scripting

Insert empty columns in a flat file

Hi, I have a tab delimited flat file, for example shown below Name Desg Loc a b c d e fI want to insert an empty column inbetween the column Desc and Loc, the result should be like shown below: Name LName Desg Loc a b c d e ... (6 Replies)
Discussion started by: sampoorna
6 Replies

3. Shell Programming and Scripting

perl: Read array from a flat file

Hello Guru's I want to read an array into a flatfile Please let me know how to do the same So far this the below code use strict; use warnings; open (my $data , '<', $ARGV)|| die "could not open $ARGV:\n$!"; my @array=(<$data>); my @sorted=sort... (8 Replies)
Discussion started by: Pratik4891
8 Replies

4. UNIX for Dummies Questions & Answers

Audit Flat File - # of Columns / Rows

We receive a file which usually has 40 to 50 million rows. I want to set up an audit process by which everytime we receive a file we audit it for # of rows and total number of columns. So if the # of rows is around 1 million on a particular day, I want to raise a flag or send an email....and if... (3 Replies)
Discussion started by: priya33184
3 Replies

5. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

6. Shell Programming and Scripting

How to read the first column in a flat file with ~ as delimiter

I have one flat file like below id1~col~batch1 id2~col2~batch2 id3~col3~batch3 I need to read the first column one by one and I need to write one db2 query based on that column1 Like for (i=0;i<=10;i++) do insert into table column (con_id) values (select column from table where... (4 Replies)
Discussion started by: siri_886
4 Replies

7. Shell Programming and Scripting

how to read fixed length flat file....

Hi Gurus, Thanks in advance... I am new to writing shell scripting and help me out reading a flat file with fixed length. I have a fixed length flat file with storename(lenth 6) , emailaddress(lenth 15), location(10). There is NO delimiters in that file. Like the following str00001.txt... (2 Replies)
Discussion started by: willywilly
2 Replies

8. UNIX for Advanced & Expert Users

limiting characters upto <xyz> columns

Hi, Recently i did some code changes in one of the text file. During the code review,i've been asked to allign the comments in this file to XYZ columns(say XYZ=40). Now the problem is that this file is a huge one and it would be really pathetic if i go ahead and do it manually. I think... (1 Reply)
Discussion started by: amit4g
1 Replies

9. Shell Programming and Scripting

How to read lines from a flat file

i have some commands written line by line in one flat file i have to read each linefrom this file(file name passed as parameter) and then i have to execute this How can i do it? (2 Replies)
Discussion started by: bihani4u
2 Replies

10. Shell Programming and Scripting

Help with Data Positioning from Columns in a flat file.

Hi All, I have used this forum many times to solve my many scripting problems. This time, I would like to seek some answers to a problem that I've been head scratching quite a bit on. My Example: I am converting a 2000-byte file into a 300-byte file this file has no delimiters and hardly any... (3 Replies)
Discussion started by: oott1
3 Replies
Login or Register to Ask a Question