Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Using powershell to check and removing duplicate entries

$
0
0

Hi Guys,

I have been trying to get my head around powershell to check a csv file. It needs to read in each line in the csv and compare it to the last one and only pull out the entry with the newest time stamp. The data is something like this (btw it has no headers pulled into the csv file).

UID,Type,Sub,Blank,deviceID,Brand,V#,OS,DType,Blank,Date/time

TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-22T10:59:40.345Z
TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-22T11:00:40.500Z
TT1234567,PRINT,7DAY_SUB,,f04f7c213b0f,kftt,2,KINDLE,Tablet,,2014-09-23T11:25:16.303Z
TT1234567,PRINT,7DAY_SUB,,f04f7c213b0f,kftt,2,KINDLE,Tablet,,2014-09-23T11:25:18.303Z
TT1234567,PRINT,7DAY_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T14:48:23.668Z
TT1234567,PRINT,7DAY_SUB,,08606eb42491,nexus7,4,4,ANDROID,Tablet,,2014-09-24T14:48:24.700Z
p@gmail.com,DIGITAL,DIG_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T15:09:08.359Z
p@gmail.com,DIGITAL,DIG_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T15:09:09.468Z
TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-25T11:59:40.345Z
TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-25T11:59:45.345Z

Output to file should be like the following.

TT1234567,PRINT,7DAY_SUB,,7DD758034,iPad3,6,IOS,Tablet,,2014-09-25T11:59:45.345Z
TT1234567,PRINT,7DAY_SUB,,f04f7c213b0f,kftt,2,KINDLE,Tablet,,2014-09-23T11:25:18.303Z
TT1234567,PRINT,7DAY_SUB,,08606eb42491,nexus7,4,4,ANDROID,Tablet,,2014-09-24T14:48:24.700Z
p@gmail.com,DIGITAL,DIG_SUB,,08606eb42491,nexus7,4.4,ANDROID,Tablet,,2014-09-24T15:09:09.468Z

Same UID can have multiple devices we want to know all the devices and the latest time stamp. As you can see thatTT1234567 used the ipad on the 2014-09-22T11:00:40.500Zbut then used it again on the 2014-09-25T11:59:45.345Z we only want the newest time stamp for that device.

I hope you guys can help me out. 



Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>