[ncl-talk] deleting rows from csv file

Dennis Shea shea at ucar.edu
Mon Dec 16 20:44:17 MST 2019


hi Michael,
Attached is a library containing few 'simple' functions that eliminate
duplicates. The were never made 'public'  :-(
It also uses:

*https://www.ncl.ucar.edu/Document/Functions/Contributed/get1Dindex.shtml*
<https://www.ncl.ucar.edu/Document/Functions/Contributed/get1Dindex.shtml>

It does return the first of the 'key' values ... not the last.

%> ncl tst.notaro_elim_dup.ncl

Happy Holidays!
D



On Mon, Dec 16, 2019 at 12:48 PM Michael Notaro via ncl-talk <
ncl-talk at ucar.edu> wrote:

> I have a lot of csv files with columns of day, time, and temperature
> such as below.
> Anytime I have consecutive rows with the same day and time,
> as highlighted below, I was to only keep the last row and remove
> the other duplicates.
> Does anyone have any suggestions in NCL or other command line?
>
> I did see this potential solution using sed, but it doesn't work in
> my mac os environment.
>
> https://unix.stackexchange.com/questions/265540/delete-consecutive-lines-in-csv-with-duplicate-values-in-one-field-but-keep-the
>
> DAY    TIME   TEMP
>  83.,   0.00,  -6.32
>  83.,  60.00,  -6.58
>  83., 120.00,  -6.80
>  83., 180.00,  -7.22
>  83., 240.00,  -7.10
>  83., 300.00,  -7.47
>  83., 360.00,  -7.69
>  83., 420.00,  -7.50
>  83., 480.00,  -6.75
>  83., 540.00,  -5.49
>  83., 600.00,  -4.54
>  83., 660.00,  -3.30
>  83., 720.00,  -2.42
>  83., 780.00,  -1.67
>  83., 840.00,  -1.64
>  83., 900.00,  -2.08
>  83., 960.00,  -2.99
>  83.,1020.00,  -4.07
>  83.,1080.00,  -5.17
>  83.,1140.00,  -6.52
>  83.,1200.00,  -7.60
>  83.,1260.00,  -8.56
>  83.,1320.00,  -8.93
>  83.,1380.00,  -9.65
>  84.,   0.00, -10.13
>  84.,  60.00, -10.29     * want to remove
>  84.,  60.00, -10.46     * want to keep
>  84., 120.00, -10.72
>  84., 180.00, -10.97
>
> Thanks, Michael
>
> Michael Notaro
> Associate Director
> Nelson Institute Center for Climatic Research
> University of Wisconsin-Madison
> Phone: (608) 261-1503
> Email: mnotaro at wisc.edu
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191216/373a231b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eliminate_dups.ncl
Type: application/octet-stream
Size: 3954 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191216/373a231b/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tst.notaro_elim_dup.ncl
Type: application/octet-stream
Size: 1070 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191216/373a231b/attachment-0001.obj>


More information about the ncl-talk mailing list