06-19-2009
[HELP] - Delete rows on a CSV file
Hello to all members,
I am very new in unix stuff (shell scripting), but a want to learn a lot. I am a ex windows user but now i am absolutely Linux super user...
So i am tryng to made a function to do this:
I have two csv files only with numbers, the first one a have:
1
2
3
4
5
in the second file i have:
2
3
5
So the result i want in my new file is:
1
4
I compare the two files and all the numbers that are not equal it will be written in a new file.
Until now i can only grep the numbers that are the same in both files.
for number in `cat <File1.csv>; do
grep $number <File2.csv>
done
Can anyone help me with this?
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I have a file having 1000 rows. Now I would like to remove 10 rows from it. Plz give me the script.
Eg:
input file like
4 1 4500.0 1
5 1 1.0 30
6 1 1.0 4500
7 1 4.0 730
7 2 500000.0 730
8 1 785460.0 45
8 7 94255.0 30
9 1 31800.0 30
9 4 36000.0 30
10 1 15000.0 30... (5 Replies)
Discussion started by: suresh3566
5 Replies
2. Shell Programming and Scripting
Hello,
I am supposed to process about 100 csv files. But these files have some extra lines at the bottom of the file. these extra lines start with a header for each column and then some values below. These lines are actually a summary of the actual data and not supposed to be processed. These... (8 Replies)
Discussion started by: cobroraj
8 Replies
3. Shell Programming and Scripting
I need to delete rows based on the number of lines in a different file, I have a piece of code with me working but when I merge with my C application, it doesnt work.
sed '1,'\"`wc -l < /tmp/fileyyyy`\"'d' /tmp/fileA > /tmp/filexxxx
Can anyone give me an alternate solution for the above (2 Replies)
Discussion started by: Muthuraj K
2 Replies
4. Shell Programming and Scripting
I have CSV file that contains data in the format as shown below:
ABC, 67, 56, 67, 78, 89, 76, 55
PDR, 85, 83, 83, 72, 82, 89, 83
MPG, 86, 53, 54, 65, 23, 54, 75
..
..
..
..
I want to create a script that will pull out the rows from the above sheet and paste it into another CSV file.... (12 Replies)
Discussion started by: pankajusc
12 Replies
5. Shell Programming and Scripting
Hi,
I need help to remove blank rows at the end of file.
Sample data:
"Oslo, Symra kino",Oslo,130-7,Symra 1,130-7-91
"Tønsberg, Brygga Kino SF",Tønsberg,202-1,Tønsberg SF 4,202-1-4
,,,,
,,,,
,,,,
,,,,
Expected data:
"Oslo, Symra kino",Oslo,130-7,Symra 1,130-7-91
"Tønsberg, Brygga... (6 Replies)
Discussion started by: cnraja
6 Replies
6. Shell Programming and Scripting
Hello list,
I am working on a csv file which contains two fields per record which contain IP addresses. What I am trying to do is find records which have identical fields(IP addresses) which occur 4(four) times, and if they do, delete all records with that specific identical field(ip address).
... (4 Replies)
Discussion started by: landossa
4 Replies
7. Shell Programming and Scripting
Hi All,
I have many of files(.csv) of the format given below.
Date,Name,Location
04/02/2012,A,India
,B,China
,C,USA
Like this I have 1000's of rows and many columns in all my files.
I need a shell script to copy down the Date(in this example column1) to the next 2 rows below(in the... (8 Replies)
Discussion started by: ks_reddy
8 Replies
8. Shell Programming and Scripting
Hi,
I have a requirement to convert rows into columns. data looks like:
c1,c2,c3,..
r1,r2,r3,..
p1,p2,p3,..
and so on..
output shud be like this:
c1,r1,p1,..
c2,r2,p2,..
c3,r3,p3,..
Thanks in advance, (12 Replies)
Discussion started by: Divya1987
12 Replies
9. Shell Programming and Scripting
Hello Everyone,
I am trying to find a way to take a .csv file with 7 columns and a ton of rows (over 600,000) and remove the entire row if the cell in forth column is blank.
Just to give you a little background on why I am doing this (just in case there is an easier way), I am pulling... (3 Replies)
Discussion started by: MrTuxor
3 Replies
10. UNIX for Beginners Questions & Answers
How can i get the duplicates rows from a file using unix, for example i have data like
a,1
b,2
c,3
d,4
a,1
c,3
e,5
i want output to be like
a,1
c,3 (4 Replies)
Discussion started by: ggupta
4 Replies
LEARN ABOUT ULTRIX
resize
resize(1X) MIT X11R4 resize(1X)
Name
resize - utility to set TERMCAP and terminal settings to current window size
Syntax
resize [-u] [-s [row col]]
Description
The uitility prints a shell command for setting the TERM and TERMCAP environment variables to indicate the current size of xterm window
from which the command is run. For this output to take effect, resize must either be evaluated as part of the command line (usually done
with a shell alias or function) or else redirected to a file which can then be read in. From the C shell (usually known as /bin/csh), the
following alias could be defined in the user's .cshrc:
% alias rs 'set noglob; `eval resize`'
After resizing the window, the user would type:
% rs
Users of versions of the Bourne shell (usually known as /bin/sh) that do not have command functions will need to send the output to a tem-
porary file and the read it back in with the ``.'' command:
$ resize >/tmp/out
$ . /tmp/out
Options
The following options may be used with resize:
-u This option indicates that Bourne shell commands should be generated even if the user's current shell is not /bin/sh.
-c This option indicates that C shell commands should be generated even if the user's current shell is not /bin/csh.
-s [rows columns]
This option indicates that the Sun console escape sequences will be used instead of the special xterm escape code. If rows and col-
umns are given, resize will ask the xterm to resize itself. However, the window manager may choose to disallow the change.
Restrictions
The -u or -c must appear to the left of -s if both are specified.
There should be some global notion of display size; termcap and terminfo need to be rethought in the context of window systems. (Fixed in
4.3BSD, and ULTRIX-32 1.2)
Files
For the base termcap entry to modify.
User's alias for the command.
See Also
csh(1), tset(1), xterm(1X)
resize(1X)