Sponsored Content
Top Forums Shell Programming and Scripting Honey, I broke awk! (duplicate line removal in 30M line 3.7GB csv file) Post 302894816 by Michael Stora on Thursday 27th of March 2014 12:01:25 PM
Old 03-27-2014
My original code spits out about 2.5 Gb (which is less than the full dataset) after about 70 min and then never completes.

I tried Chubler_X's code above and terminated it after 16 hours with no output.

One way I can definitely split without duplicates spanning split files is to split on date. It only takes about one minute to split the data in two with the following code:
Code:
awk -F, -v startDT="$startDate" -v endDT="$endDate" '
            BEGIN { s=mktime(startDT); e=mktime(endDT)}
            NR == 1 {print}
            NR > 1 { t = $6; gsub(/\-|:/, " ", t); t = mktime(t); if ( s <= t && t <= e) {print} }'

Mike

Last edited by Michael Stora; 03-27-2014 at 01:28 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removal of Duplicate Entries from the file

I have a file which consists of 1000 entries. Out of 1000 entries i have 500 Duplicate Entires. I want to remove the first Duplicate Entry (i,e entire Line) in the File. The example of the File is shown below: 8244100010143276|MARISOL CARO||MORALES|HSD768|CARR 430 KM 1.7 ... (1 Reply)
Discussion started by: ravi_rn
1 Replies

2. Shell Programming and Scripting

Awk not working due to missing new line character at last line of file

Hi, My awk program is failing. I figured out using command od -c filename that the last line of the file doesnt end with a new line character. Mine is an automated process because of this data is missing. How do i handle this? I want to append new line character at the end of last... (2 Replies)
Discussion started by: pinnacle
2 Replies

3. Shell Programming and Scripting

awk script to remove duplicate rows in line

i have the long file more than one ns and www and mx in the line like . i need the first ns record and first www and first mx from line . the records are seperated with tthe ; i am try ing in awk scripting not getiing the solution. ... (4 Replies)
Discussion started by: kiranmosarla
4 Replies

4. Shell Programming and Scripting

reading a file inside awk and processing line by line

Hi Sorry to multipost. I am opening the new thread because the earlier threads head was misleading to my current doubt. and i am stuck. list=`cat /u/Test/programs`; psg "ServTest" | awk -v listawk=$list '{ cmd_name=($5 ~ /^/)? $9:$8 for(pgmname in listawk) ... (6 Replies)
Discussion started by: Anteus
6 Replies

5. Shell Programming and Scripting

Updating a line in a large csv file, with sed/awk?

I have an extremely large csv file that I need to search the second field, and upon matches update the last field... I can pull the line with awk.. but apparently you cant use awk to directly update the file? So im curious if I can use sed to do this... The good news is the field I want to... (5 Replies)
Discussion started by: trey85stang
5 Replies

6. Shell Programming and Scripting

Read csv file line by line

Folks , i want to read a csv file line by line till the end of file and filter the text in the line and append everything into a variable. csv file format is :- trousers:shirts,price,50 jeans:tshirts,rate,60 pants:blazer,costprice,40 etc i want to read the first line and get... (6 Replies)
Discussion started by: venu
6 Replies

7. Shell Programming and Scripting

awk concatenate every line of a file in a single line

I have several hundreds of tiny files which need to be concatenated into one single line and all those in a single file. Some files have several blank lines. Tried to use this script but failed on it. awk 'END { print r } r && !/^/ { print FILENAME, r; r = "" }{ r = r ? r $0 : $0 }' *.txt... (8 Replies)
Discussion started by: sdf
8 Replies

8. Shell Programming and Scripting

Duplicate line removal matching some columns only

I'm looking to remove duplicate rows from a CSV file with a twist. The first row is a header. There are 31 columns. I want to remove duplicates when the first 29 rows are identical ignoring row 30 and 31 BUT the duplicate that is kept should have the shortest total character length in rows 30... (6 Replies)
Discussion started by: Michael Stora
6 Replies

9. UNIX for Dummies Questions & Answers

Using awk to remove duplicate line if field is empty

Hi all, I've got a file that has 12 fields. I've merged 2 files and there will be some duplicates in the following: FILE: 1. ABC, 12345, TEST1, BILLING, GV, 20/10/2012, C, 8, 100, AA, TT, 100 2. ABC, 12345, TEST1, BILLING, GV, 20/10/2012, C, 8, 100, AA, TT, (EMPTY) 3. CDC, 54321, TEST3,... (4 Replies)
Discussion started by: tugar
4 Replies

10. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
ch_rc(1M)																 ch_rc(1M)

NAME
ch_rc - change system configuration file SYNOPSIS
root] {parameter|parameter=value}...] [file...] DESCRIPTION
manages the addition, modification, removal, and retrieval of information stored in files having the format of those in the directory. Parameter names are treated as strings. Thus, has no special meaning to in relation to other parameters named Options file Specify the file(s) to be used as the configuration database. If no file is specified, the set of files used by defaults to and all files in the directory. Modification and deletion of configuration parameters occurs in the file where the parameter is found. Add or modify a parameter definition. For each parameter specified on the command line, if the parameter is found in the specified (or default) files, it is modified to reflect the speci- fied value. If the parameter is not found, it is added to the specified file(s). If a new parameter is being defined, one or more files must be specified on the command line; the specified files are those in which the parameter will be defined. Remove a parameter definition. For each parameter name specified on the command line, remove any occurrence of that parameter from the specified file(s). List configuration values. For each parameter specified on the command line, output every definition of the parameter from the specified file(s). Output consists of only the values, one per line. Specify a parameter name or name/value pair. If a name and value is expected, but only a name is specified, the value will be set to the empty string. For example, specifying or will result in and respectively. Due to shell quoting rules, if you need a quoted parameter value, you must protect the quotes from the shell. For exam- ple, yields: which is an error, whereas, yields: Verbose. When used with the option, the option causes a verbose listing to be output. This listing includes a filename followed by the entire line containing the specified parameter for each occurrance of the parameter. The option is used to list all occurances of array parameters matching the parameters specified on the command line. For example, may emit the following output: Normally, the files specified on the command line are used as specified. By specifying a root directory with the option, all files (including the default files if none are specified) will be interpreted relative to root. For example, if root is specified as and is specified on the command line, it will be interpreted as RETURN VALUE
exits with one of the following values: 0 add/delete/list successful 1 command line syntax/usage error 2 can not access one or more of the listed (or default) files 3 can not open/create/write file 4 memory error 5 no files specified on command line for add option EXAMPLES
Files in the directory have the following format: WARNINGS
does not interpret configuration files; it only does pattern matching. As a result, if comments appear on lines containing parameter defi- nitions, the comments will also appear in output when using the option. cannot parse multiple parameter definitions which occur on the same line of a file. AUTHOR
was developed by HP. FILES
system configuration database driver file directory containing system configuration files SEE ALSO
rc.config(4). ch_rc(1M)
All times are GMT -4. The time now is 09:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy