sed isn't really the right tool for dealing with columns. awk would be the correct tool, it understands columns as columns without weird regex convolutions.
As long as your CSV is actually comma separated -- uses , to separate columns and nowhere else -- this may work:
If your CSV isn't actually a CSV, a recursive parser that understands quotes is required and things start getting hard.
Hello,
I have many csv file, but I would like to delete lines with some values in a column conditionally.
My example look like this,
ex1e, ex2g, ex39, pasg, ssg, mrlc, pc, kb, coop
-112, -53, -177, 64, 62, 71, 1, 487, 20
-101, -61, -53, 0, 32767, 51, 0, ... (6 Replies)
I am trying to remove the ita from this file:
"1234ita","john","smith"
"56789ita","jim","thomas"
the command i am using is:
sed '/^ita/d' infile.csv > outfile.csv
it is running but doing nothing, very rarely use sed so trying to learn it any help would be appreciated (2 Replies)
I have a large CSV files (e.g. 2 million records) and am hoping to do one of two things. I have been trying to use awk and sed but am a newbie and can't figure out how to get it to work. Any help you could offer would be greatly appreciated - I'm stuck trying to remove the colon and wildcards in... (6 Replies)
Hi All,
i have a csv file .
In the 7th column i have data that has line feed in it.
Requirement is to remove the line feed from the 7th column whenever it appears
There are 11 columns in the file
C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11
The value in C7 contains line feed ( Alt + Enter ),... (2 Replies)
I have a data file that has 14 columns. I cannot use awk or perl but sed is installed on my host. I would like to delete a line if fields 10, 11 or twelve is greater than 999.99. How is this done using sed? :wall:
sed '/^*,*,*,*,*,*,*,*,*,*,*,*,*,*,/d' infile
1 2 3 4 ... (2 Replies)
Hello people,
I am having problem to sort, sed and zero padding of column in csv file.
7th column only.
Input of csv file:
1,2,3,4,5,6,4/1/2010 12:00 AM,8
1,2,3,4,5,6,3/11/2010 9:39 AM,8
1,2,3,4,5,6,5/12/2011 3:43 PM,8
1,2,3,4,5,6,12/20/2009 7:23 PM,8
Output:... (5 Replies)
Hi,
I need to remove first column from a csv file and i can do this by using below command.
cut -f1 -d, --complement Mytest.csv
I need to implement this in shell scripting, Whenever i am using the above command alone in command line it is working fine.
I have 5 files in my directory and... (3 Replies)
Discussion started by: Samah
3 Replies
LEARN ABOUT MINIX
cut
CUT(1) General Commands Manual CUT(1)NAME
cut - select out columns of a file
SYNOPSIS
cut [ -b | -c] list [file...]
cut -f list [-d delim] [ -s]
OPTIONS -b Cut specified bytes
-c Select out specific characters
-d Change the column delimiter to delim
-f Select out specific fields that are separated by the
-i Runs of delimiters count as one
-s Suppres lines with no delimiter characters, when used
EXAMPLES
cut -f 2 file # Extract field 2
cut -c 1-2,5 file # Extract character columns 1, 2, and 5
cut -c 1-5,7- file # Extract all columns except 6
DESCRIPTION
[file...]" delimiter character ( see delim)" with the -f option. Lines with no delimiters are passwd through untouched"
Cut extracts one or more fields or columns from a file and writes them on standard output. If the -f flag is used, the fields are sepa-
rated by a delimiter character, normally a tab, but can be changed using the -d flag. If the -c flag is used, specific columns can be
specified. The list can be comma or BLANK separated. The -f and -c flags are mutually exclusive. Note: The POSIX1003.2 standard requires
the option -b to cut out specific bytes in a file. It is intended for systems with multi byte characters (e.g. kanji), since MINIX uses
only one byte characters, this option is equivalent to -c. For the same reason, the option -n has no effect and is not listed in this man-
ual page.
SEE ALSO sed(1), awk(9).
CUT(1)