02-29-2012
Inverse of Cut
Hi List,
I have a CSV file which I am manipulating. Each time I receive the CSV for processing, there will be extra columns of data.
Here's what I want to do; I want to be able to remove specific columns from the CSV data file, but keep the remaining columns, where the remaining columns are variable in how many columns there are. (there will be more columns each time the script is run on new data)
Lets say I want to remove columns 2,3,4,5,10 and keep the rest
Normally, in a fixed length CSV, which has the same amount of columns every time it is processed, say 20 columns each time, I would use the following command to achieve this: (thereby specifying columns I do want)
cut -d"," -f 1,6,7,8,9,11,12,13,14,15,16,17,18,19,20
But since the amount of columns will increase each time I have to run this process, then I need a means of specifying columns that I don't want (inverse cut) rather than what I do want. Perhaps this could be achieved in sed or awk..
Has anyone got any ideas?
Any help much appreciated.
thanks,
land
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am trying to discover the sequence of escape characters that I need to pass ksh in order to turn inverse video on and off. I need this information for two reasons:
* I want to include inverse video text in some shell scripts
* I wish to highlight a section of an /etc/motd file
Thanks for... (2 Replies)
Discussion started by: sam_pointer
2 Replies
2. UNIX for Dummies Questions & Answers
I have few days to complete my awk homework. But I'm stucked. i hope some1 will help me out.
I have to inverse n x n matrix, but I have problems with finding the determinant of the matrix.
I found the algoritm, how to find a determinant of n x n matrix:... (0 Replies)
Discussion started by: vesyyr
0 Replies
3. Shell Programming and Scripting
I need to inverse a matrix given in a file.
The problem is I'm stuck with writing determinant finding algoritm into code.
I found this algoritm about finding determinant of nxn matrix. This is what i need:
Matrices and Determinants
and here:
a11 a12 a13
a21 a22 a23
a31 a32 a33... (0 Replies)
Discussion started by: vesyyr
0 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
Is there an option for 'rm' to "remove everything but these files"?
For instance if I have:
a.txt <-- I just want to remove this one
a_1.txt
a_2.txt
Is there an option ? for this:
rm -? *_*.txt
Thanks,
ScKaSx (4 Replies)
Discussion started by: ScKaSx
4 Replies
5. Shell Programming and Scripting
Hi,
I'm trying to wtite a script which actually print the text which doesn't contain a word , i mean to say.
eg:- if a file contains the follwoing data
Hello how ru ???
What ru doing ?
what is the % of data contained ???
I want to write a script such that it prints the line excluding... (1 Reply)
Discussion started by: nagios
1 Replies
6. Shell Programming and Scripting
I am totally unexperienced in writing scripts of any kind.
I am working on Mac OS X and would like to run a shell script to find files in a directory that do not conform to a specific naming convention and print to a text file in the same directory.
For example, I have a folder called... (9 Replies)
Discussion started by: j_alicea
9 Replies
7. Programming
I ask of you but yet another simplistic question that I hope can be answered. Its better explained showing my code. Here is my list(tmp_pkglist), which contains a list of all Debian (Jessie) packages:
snippet
'zssh (1.5c.debian.1-3.2+b1 , 1.5c.debian.1-3.2 )',
'zsync (0.6.2-1)',
'ztex-bmp... (2 Replies)
Discussion started by: metallica1973
2 Replies
8. UNIX for Beginners Questions & Answers
I have an interactive script which sorts and processes a variety of filetypes from an unsorted folder into newly created directories.
The script works great, But I was wondering how I could generate a script with an inverse action so that I could unwind / undo the executed script and its sorting... (3 Replies)
Discussion started by: Braveheart
3 Replies