Sponsored Content
Top Forums Shell Programming and Scripting Make copy of text file with columns removed (based on header) Post 302931578 by LMHmedchem on Wednesday 14th of January 2015 01:31:21 AM
Old 01-14-2015
Make copy of text file with columns removed (based on header)

Hello,

I have some tab delimited text files with a three header rows. The headers look like, (sorry the tabs look so messy).

Code:
index	group	Name	input	input	input	input	input	input	input	input	input	input	input
int	char	string	double	double	double	double	double	double	double	double	double	double	double
id	group	Name	AtR_Ptb_L	flatness	inv_dx2	rvalHyd	sumLip	xv0	dxv1	Gmax	k2	Spyridin_N	Salph_N

The files could have any number of columns. What I need to do is simple. I just need to copy the file with one or more columns removed. The columns to be removed would be specified by the value in the third row. For example, I could want the files with columns "dxv1" and "k2" removed.
Code:
index	group	Name	input	input	input	input	input	input	input	input	input
int	char	string	double	double	double	double	double	double	double	double	double
id	group	Name	AtR_Ptb_L	flatness	inv_dx2	rvalHyd	sumLip	xv0	Gmax	Spyridin_N	Salph_N

The order of the remaining columns should be the same. It doesn't matter how the list of columns to be removed is formatted. It can be any kind of list.

I have read posts about how to copy specific columns with cut or awk, but not how to skip specific cols and copy everything else. One thing to do would be to find the position of the cols to be removed and use cut, but how to set that up to work in a general implementation is a bit unclear to me. I also suspect that awk would be more efficient.

Any suggestions?

LMHmedchem
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Merging two files based on two columns to make a third file

Hi there, I'm trying to merge two files and make a third file. However, two of the columns need to match exactly in both files AND I want everything from both files in the output if the two columns match in that row. First file looks like this: chr1 10001980 T A Second... (12 Replies)
Discussion started by: infiniteabyss
12 Replies

2. Shell Programming and Scripting

Copy and Paste Columns in a Tab-Limited Text file

I have this text file with a very large number of columns (10,000+) and I want to move the first column to the position of the six column so that the text file looks like this: Before cutting and pasting ID Family Mother Father Trait Phenotype aaa bbb ... (5 Replies)
Discussion started by: evelibertine
5 Replies

3. UNIX for Dummies Questions & Answers

Extracting rows from a text file based on the values of two columns (given ranges)

Hi, I have a tab delimited text file with multiple columns. The second and third columns include numbers that have not been sorted. I want to extract rows where the second column includes a value between -0.01 and 0.01 (including both numbers) and the first third column includes a value between... (1 Reply)
Discussion started by: evelibertine
1 Replies

4. Shell Programming and Scripting

Reading columns from a text file and to make an array for each column

Hi, I am not so familiar with bash scripting and would appreciate your help here. I have a text file 'input.txt' like this: 2 3 4 5 6 7 8 9 10 I want to store each column in an array like this a ={2 5 8}, b={3 6 9}, c={4 7 10} so that i can access any element, e.g b=6 for the later use. (1 Reply)
Discussion started by: Asif Siddique
1 Replies

5. Shell Programming and Scripting

Extract columns based on header

Hi to all, I have two files. File1 has no header, two columns: sample1 A sample2 B sample3 B sample4 C sample5 A sample6 D sample7 D File2 has a header, except for the first 3 columns (chr,start,end). "sample1" is the header for the 4th ,5th ,6th columns, "sample2" is the header... (4 Replies)
Discussion started by: aec
4 Replies

6. Emergency UNIX and Linux Support

Average columns based on header name

Hi Friends, I have files with columns like this. This sample input below is partial. Please check below for main file link. Each file will have only two rows. ... (8 Replies)
Discussion started by: jacobs.smith
8 Replies

7. UNIX for Beginners Questions & Answers

Keep only columns in first two rows based on partial header pattern.

I have this code below that only prints out certain columns from the first two rows (doesn't affect rows 3 and beyond). How can I do the same on a partial header pattern “G_TP” instead of having to know specific column numbers (e.g. 374-479)? I've tried many other commands within this pipe with no... (4 Replies)
Discussion started by: aachave1
4 Replies

8. Shell Programming and Scripting

Find columns in a file based on header and print to new file

Hello, I have to fish out some specific columns from a file based on the header value. I have the list of columns I need in a different file. I thought I could read in the list of headers I need, # file with header names of required columns in required order headers_file=$2 # read contents... (11 Replies)
Discussion started by: LMHmedchem
11 Replies

9. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
HYPERG(3pm)						User Contributed Perl Documentation					       HYPERG(3pm)

NAME
PDL::GSLSF::HYPERG - PDL interface to GSL Special Functions DESCRIPTION
This is an interface to the Special Function package present in the GNU Scientific Library. SYNOPSIS
FUNCTIONS
gsl_sf_hyperg_0F1 Signature: (double x(); double [o]y(); double [o]e(); double c) /* Hypergeometric function related to Bessel functions 0F1[c,x] = Gamma[c] x^(1/2(1-c)) I_{c-1}(2 Sqrt[x]) Gamma[c] (-x)^(1/2(1-c)) J_{c-1}(2 Sqrt[-x]) gsl_sf_hyperg_0F1 does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_1F1 Signature: (double x(); double [o]y(); double [o]e(); double a; double b) Confluent hypergeometric function for integer parameters. 1F1[a,b,x] = M(a,b,x) gsl_sf_hyperg_1F1 does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_U Signature: (double x(); double [o]y(); double [o]e(); double a; double b) Confluent hypergeometric function for integer parameters. U(a,b,x) gsl_sf_hyperg_U does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_2F1 Signature: (double x(); double [o]y(); double [o]e(); double a; double b; double c) Confluent hypergeometric function for integer parameters. 2F1[a,b,c,x] gsl_sf_hyperg_2F1 does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_2F1_conj Signature: (double x(); double [o]y(); double [o]e(); double a; double b; double c) Gauss hypergeometric function 2F1[aR + I aI, aR - I aI, c, x] gsl_sf_hyperg_2F1_conj does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_2F1_renorm Signature: (double x(); double [o]y(); double [o]e(); double a; double b; double c) Renormalized Gauss hypergeometric function 2F1[a,b,c,x] / Gamma[c] gsl_sf_hyperg_2F1_renorm does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_2F1_conj_renorm Signature: (double x(); double [o]y(); double [o]e(); double a; double b; double c) Renormalized Gauss hypergeometric function 2F1[aR + I aI, aR - I aI, c, x] / Gamma[c] gsl_sf_hyperg_2F1_conj_renorm does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. gsl_sf_hyperg_2F0 Signature: (double x(); double [o]y(); double [o]e(); double a; double b) Mysterious hypergeometric function. The series representation is a divergent hypergeometric series. However, for x < 0 we have 2F0(a,b,x) = (-1/x)^a U(a,1+a-b,-1/x) gsl_sf_hyperg_2F0 does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. AUTHOR
This file copyright (C) 1999 Christian Pellegrin <chri@infis.univ.trieste.it> All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file. The GSL SF modules were written by G. Jungman. perl v5.14.2 2012-05-30 HYPERG(3pm)
All times are GMT -4. The time now is 08:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy