Sponsored Content
Full Discussion: Last line omit
Top Forums UNIX for Dummies Questions & Answers Last line omit Post 302807567 by Scott on Wednesday 15th of May 2013 01:51:00 AM
Old 05-15-2013
You could try:
Code:
$ grep -vc ^$ file.csv

depending on the definition of "empty" and, of course, an assumption that a row in a CSV file with no values still is written with delimiters.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Omit repeating lines

Can someone help me with the following 2 objectives? 1) The following command is just an example. It gets a list of all print jobs. From there I am trying to extract the printer name. It works with the following command: lpstat -W "completed" -o | awk -F- '{ print $1}' Problem is, I want... (6 Replies)
Discussion started by: TheCrunge
6 Replies

2. Shell Programming and Scripting

Command to list only files omit directories.

Hi All I am writting a script that does a comparison between files in 2 diffectent directories. To do this I need a command that will list out only the files in a give directory and omit any sub dorectories with that directory. But I am unable to find it. Please Help. I tried ls... (5 Replies)
Discussion started by: Veenak15
5 Replies

3. Shell Programming and Scripting

how to omit data from a file created in a script

I am using the fallowing script. this script seems to work fine except the file has data I do not wish to have. Is there away to omit that data. I will first provide the scrip and then a sample of the data the way it looks and then a sample of how I would like the data to look. Thanks for any... (3 Replies)
Discussion started by: krisarmstrong
3 Replies

4. Shell Programming and Scripting

Omit Blank Lines while comparing two files.

Hello All, I am writting file comparison Utility and I have encountered such a senario where there are 2 files such as follows- 1#!/usr/local/bin/python 2 import gsd.scripts.admin.control.gsdPageEscalate 3.gsd.scripts.admin.control.gsdPageEscalate.main() 1 #!/usr/local/bin/python... (10 Replies)
Discussion started by: Veenak15
10 Replies

5. UNIX for Dummies Questions & Answers

omit strings from grep result

Hi, I know this is a really dumb question, and I used to know how to do this, but I forgot and I can't seem to find the command online anywhere: When I grep a string, how do I filter the results so that lines containing a certain string are OMITTED! for example: grep 'string' *.txt ... (2 Replies)
Discussion started by: juliette salexa
2 Replies

6. Shell Programming and Scripting

using awk to omit certain characters

I have a file called file.txt with multiple lines in them. I'm trying to remove the first 2 characters and the last 2 with awk. '.batman') '.superman') '.dragonheart') .'superduper') I tried doing the following and able to get rid of the first two characters. How do I remove the trailing... (5 Replies)
Discussion started by: zerofire123
5 Replies

7. Shell Programming and Scripting

How to omit a part of the string

I have a file, f1 with content: File f1: abc_English_Dlr def_123_English_Dlr qwe_98_yu_English_Dlr dsw_1_English_Dlr I want to remove "_English_Dlr" from it. I used cut command but the problem is there may be a case for getting 1 or more fields before _English_Dlr . So Cut... (8 Replies)
Discussion started by: karumudi7
8 Replies

8. Shell Programming and Scripting

how to omit the output of the at now command

Hi Everyone, I'm invoking the following command by a script: at now < /home/d01plmi1/rep/start_replication.sh > /dev/null/ 2>&1 but everytime is runs it put a message into the mail box of the userid executing the command. How can I redirect this so I can stop these notifications... (4 Replies)
Discussion started by: arizah
4 Replies

9. Shell Programming and Scripting

Combine/omit data from 2 files

i made a script on my own. this is for the inventory to all of my AWS servers, and i run it to all of my servers to get the hostname, please look at file2. Then i need some data in file3 as well,. i need to combine them #cat file1 192.10.1.41 server.age.com ###### 192.10.0.40 ssh cant... (10 Replies)
Discussion started by: kenshinhimura
10 Replies

10. Red Hat

Rsync - hot to omit MOTD/banners

I'm working on an rsync script and I'd like it to omit the MOTD banners and NOT output them to the file. I tried the --no-motd argument in the command but for some reason the MOTD still continues to appear. Can anyone advise? (10 Replies)
Discussion started by: infrared013
10 Replies
csv(n)								  CSV processing							    csv(n)

NAME
csv - Procedures to handle CSV data. SYNOPSIS
package require Tcl 8.3 package require csv ?0.3? ::csv::join values {sepChar ,} ::csv::joinlist values {sepChar ,} ::csv::read2matrix chan m {sepChar ,} {expand none} ::csv::read2queue chan q {sepChar ,} ::csv::report cmd matrix ?chan? ::csv::split line {sepChar ,} ::csv::split2matrix m line {sepChar ,} {expand none} ::csv::split2queue q line {sepChar ,} ::csv::writematrix m chan {sepChar ,} ::csv::writequeue q chan {sepChar ,} DESCRIPTION
The csv package provides commands to manipulate information in CSV FORMAT (CSV = Comma Separated Values). COMMANDS
The following commands are available: ::csv::join values {sepChar ,} Takes a list of values and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". ::csv::joinlist values {sepChar ,} Takes a list of lists of values and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". Each element of the outer list is considered a record, these are separated by newlines in the result. The elements of each record are formatted as usual (via ::csv::join). ::csv::read2matrix chan m {sepChar ,} {expand none} A wrapper around ::csv::split2matrix (see below) reading CSV-formatted lines from the specified channel (until EOF) and adding them to the given matrix. For an explanation of the expand argument see ::csv::split2matrix. ::csv::read2queue chan q {sepChar ,} A wrapper around ::csv::split2queue (see below) reading CSV-formatted lines from the specified channel (until EOF) and adding them to the given queue. ::csv::report cmd matrix ?chan? A report command which can be used by the matrix methods format 2string and format 2chan. For the latter this command delegates the work to ::csv::writematrix. cmd is expected to be either printmatrix or printmatrix2channel. The channel argument, chan, has to be present for the latter and must not be present for the first. ::csv::split line {sepChar ,} converts a line in CSV format into a list of the values contained in the line. The character used to separate the values from each other can be defined by the caller, via sepChar, but this is optional. The default is ",". ::csv::split2matrix m line {sepChar ,} {expand none} The same as ::csv::split, but appends the resulting list as a new row to the matrix m, using the method add row. The expansion mode specified via expand determines how the command handles a matrix with less columns than contained in line. The allowed modes are: none This is the default mode. In this mode it is the responsibility of the caller to ensure that the matrix has enough columns to contain the full line. If there are not enough columns the list of values is silently truncated at the end to fit. empty In this mode the command expands an empty matrix to hold all columns of the specified line, but goes no further. The overall effect is that the first of a series of lines determines the number of columns in the matrix and all following lines are truncated to that size, as if mode none was set. auto In this mode the command expands the matrix as needed to hold all columns contained in line. The overall effect is that after adding a series of lines the matrix will have enough columns to hold all columns of the longest line encountered so far. ::csv::split2queue q line {sepChar ,} The same as ::csv::split, but appending the resulting list as a single item to the queue q, using the method put. ::csv::writematrix m chan {sepChar ,} A wrapper around ::csv::join taking all rows in the matrix m and writing them CSV formatted into the channel chan. ::csv::writequeue q chan {sepChar ,} A wrapper around ::csv::join taking all items in the queue q (assumes that they are lists) and writing them CSV formatted into the channel chan. FORMAT
Each record of a csv file (comma-separated values, as exported e.g. by Excel) is a set of ASCII values separated by ",". For other lan- guages it may be ";" however, although this is not important for this case (The functions provided here allow any separator character). If a value contains itself the separator ",", then it (the value) is put between "". If a value contains ", it is replaced by "". EXAMPLE
The record 123,"123,521.2","Mary says ""Hello, I am Mary""" is parsed as follows: a) 123 b) 123,521.2 c) Mary says "Hello, I am Mary" SEE ALSO
matrix, queue KEYWORDS
csv, matrix, queue, package, tcllib csv 0.3 csv(n)
All times are GMT -4. The time now is 03:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy