Sponsored Content
Top Forums Shell Programming and Scripting Using sed to remove a column from a CSV Post 302912510 by bakunin on Friday 8th of August 2014 04:07:26 PM
Old 08-08-2014
Quote:
Originally Posted by Don Cragun
Which is more simply written as:
Code:
sed 's/[^,]*, //' file

Which is where we started,
Correct. I thought i made it clear in my posting that the original regexp already covered the double-quoted fields too. I wanted to explain how to expand this to the - more general - case where double-quoted field separator chars would not count as field separators. For this (and this alone) to achieve the more complex regexp is necessary.

bakunin
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed csv remove conditionally

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)
Discussion started by: Jae
6 Replies

2. Shell Programming and Scripting

Remove text from a csv file using sed

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)
Discussion started by: Pablo_beezo
2 Replies

3. Shell Programming and Scripting

Sed or awk script to remove text / or perform calculations from large CSV files

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)
Discussion started by: metronomadic
6 Replies

4. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, My requirement is to remove line (3 Replies)
Discussion started by: r_t_1601
3 Replies

5. Shell Programming and Scripting

Remove line feed from csv file column

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)
Discussion started by: r_t_1601
2 Replies

6. UNIX for Dummies Questions & Answers

Use sed on column (csv) file if data in colmns is greater > than?

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)
Discussion started by: Chris Eagleson
2 Replies

7. Shell Programming and Scripting

Sort, sed, and zero padding date column csv bash scripting

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)
Discussion started by: sean1357
5 Replies

8. Shell Programming and Scripting

Remove the values from a certain column without deleting the Column name in a .CSV file

(14 Replies)
Discussion started by: dhruuv369
14 Replies

9. Shell Programming and Scripting

Need a piece of shell scripting to remove column from a csv file

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
AnyData::Format::CSV(3pm)				User Contributed Perl Documentation				 AnyData::Format::CSV(3pm)

NAME
AnyData::Format::CSV - tiedhash & DBI/SQL access to CSV data SYNOPSIS
use AnyData; my $table = adTable( 'CSV', $filename,'r',$flags ); while (my $row = each %$table) { print $row->{name}," " if $row->{country} =~ /us|mx|ca/; } # ... other tied hash operations OR use DBI my $dbh = DBI->connect('dbi:AnyData:'); $dbh->func('table1','CSV', $filename,$flags,'ad_catalog'); my $hits = $dbh->selectall_arrayref( qq{ SELECT name FROM table1 WHERE country = 'us' }); # ... other DBI/SQL operations DESCRIPTION
This is a plug-in format parser for the AnyData and DBD::AnyData modules. It will read column names from the first row of the file, or accept names passed by the user. In addition to column names, the user may set other options as follows: col_names : a comma separated list of column names eol : the end of record mark, by default quote_char : the character used to quote fields " by default escape_char : the character used to escape the quote char, " by default If you are using this with DBD::AnyData, put ad_ in front of the flags, e.g. ad_eol. Please refer to the documentation for AnyData.pm and DBD::AnyData.pm for further details. AUTHOR &; COPYRIGHT copyright 2000, Jeff Zucker <jeff@vpservices.com> all rights reserved perl v5.10.1 2004-08-17 AnyData::Format::CSV(3pm)
All times are GMT -4. The time now is 01:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy