Sponsored Content
Top Forums Shell Programming and Scripting Honey, I broke awk! (duplicate line removal in 30M line 3.7GB csv file) Post 302894691 by Michael Stora on Wednesday 26th of March 2014 06:20:47 PM
Old 03-26-2014
Thanks for all the suggestions. My workaround so far has been to skip the duplicate line removal and add it to the querries I run against the database instead. This has allowed me to procede with my analysis.

I will go back and fix the database at some point however when the current deadline passes.

I will have to check closely which fields alone can indicate a duplicate record. Since the addition of a column (and therefore the length of $0) is what broke it, taking something out may help. I'm not sure as I am already taking the important columns from two types of database files and the "housekeeping columns" are not included.

Is there a way to do a checksum or fairly robust hash in awk? That might be the best way to shorten the array names which appears to what is killing awk.

Mike

PS. I would love to be using real Linux instead of Cygwin (as I do at home). Unfortunately that is a boundary condition.

Last edited by Michael Stora; 03-26-2014 at 08:03 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
shatag(1)							      Shatag								 shatag(1)

NAME
shatag - tag files with their SHA-256 checksums SYNOPSIS
shatag [-fhlLqrtuv0] [-d DATABASE] [-n NAME] [-R NAME]... [FILES]... DESCRIPTION
shatag is a tool for computing and caching SHA-256 file checksums, and efficiently search for identical file across systems. Checksums are stored using the POSIX Extended Attributes filesystem facility, and are preserved when files are moved or renamed. Checksums can be fetched from a remote host and stored in an sqlite database for fast lookups. OPTIONS
When invoked with no options, shatag just displays the cached, valid checksums. If no files are specified, it applies to all non-hidden files in the current directory. The output format is identical to the one of the sha256sum command. -0, --null Instead of outputting one record per line (like sha256sum does,) separate records with null characters. -d DATABASE, --database DATABASE Set the path of the SQLite database to query when using -l , -L or -p (The default path is $HOME/.shatagdb, overridable from the config file) Instead of a file name, a PostgreSQL database can be specified with a prefix of "pg:" followed by a psycopg2 DSN string, like: "pg:dbname=shatag user=myuser password=mypassword host=192.168.1.3" -f, --force When running with -t or -u , recompute the checksum even if the file modification time has not changed. If the old checksum differs, report the file as corrupted. -h, --help Displays the help message -l, --lookup Instead of displaying the checksums, look them up against the local database and indicate if the file exists. A yellow - mark indi- cates that the file does not exist somewhere else, a green = that the file exists at one or several remote locations, a red + that the file has a duplicate on the local system, and a magenta * that the file is empty. -L, --lookup-verbose Instead of displaying the checksums, look them up against the local database. Print all the known remote locations for identical files. -n NAME, --name NAME Name of local storage (defaults to canonical local host name). This needs to be correct if the local database contains entries for this own host. -p, --put Record found tags in the database, for duplicate detection. -q, --quiet Do not display the valid checksums when they are found. -r, --recursive Recurse trough subdirectories -R NAME, --remote NAME When using -l or -L , This is used to restrict the set of remote names to consider. If present, other storages will be ignored. -t, --tag Compute new checksums for files that don't have one, or when it is outdated. -u, --update Recompute the outdated checksums only. Be aware that this can behave counter-intuitively; outdated checksums will only exists for files that have been appended to or partially modified. Many programs dealing with small files (some well-known text editors, no- tably) will overwrite the whole file when saving, and the new file will be lacking a checksum entirely. For these cases, use -t in- stead. -v, --verbose Report encoutered files that have an outated or missing checksum. EXAMPLES
Retag a whole directory and record everything to the database: shatag -pqrt . Check files in the current directory for remote duplicates: shatag -l Show alternate locations for duplicates of a single file: shatag -L somefile FILES
~/.shatagrc YAML configuration file. Currently has only two possible configuration keys: "database", which sets the database path (by default, ~/.shatagdb) and "name" for the volume name in the database (default to canonical host name.) Examples: database: /var/lib/shatag.db # sqlite3 backend database: "pg: dbname=shatag host=localhost user=shatag password=xxxsecretpass- wordxxx" # postgres backend database: http://service.com/shatag # http backend database: insecure-https://service.com/shatag # http backend, skip ssl certificate verification BUGS
Support for non-ASCII filenames across systems of different and/or inconsistent encodings have not been fully tested. Not all option combinations are sensible. REPORTING BUGS
Report shatag bugs to the bugtracker at http://bitbucket.org/maugier/shatag, SEE ALSO
shatag-add(1), shatag-mkdb(1) Shatag 0.1 26.08.2010 shatag(1)
All times are GMT -4. The time now is 09:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy