java - How to compare two CSV file? -
i have 2 csv file 1st 1 ip geo-location csv file , second 1 have date time , ip address how compare both file , make new csv file have date time ip address , ip location(country name).how make in java?
1st file
18102015 11:35:59 93.178.13.37:2065 18102015 11:36:00 93.178.13.37:2078 18102015 11:36:21 93.178.13.37:7251 18102015 11:37:05 222.35.153.160:502 18102015 11:37:05 222.35.153.160:5050
2nd file
93.178.0.0 93.178.63.255 1571946496 1571962879 sa saudi arabia 93.178.64.0 93.178.127.255 1571962880 1571979263 ru russian federation 222.16.0.0 222.95.255.255 3725590528 3730833407 cn china
i want result:
18102015 11:35:59 93.178.13.37 2065 sa saudi arabia 18102015 11:36:00 93.178.13.37 2078 sa saudi arabia 18102015 11:36:21 93.178.13.37 7251 sa saudi arabia 18102015 11:37:05 222.35.153.160 5029 cn china 18102015 11:37:05 222.35.153.160 5050 cn china
hints:
think of dotted ip address 4 octets of 32 bit number. example, ip address 93.178.63.255 (93*(2^24)) + (178*(2^16)) + (63*(2^8)) + 255. math, , come number represents ip address.
the second file has ip ranges (low high). if convert low , high ip addresses of range, you'll come 2 numbers. therefore, if you're trying detect if ip address (from file #1) within range (in file #2), it's simple. if ip >= lowip && ip <= highip it's in range.
further advice: parse file #2 , create objects each of them. object have notably starting ip address, ending ip address, , country. can parse file #1, search within collection of objects match, , output need to.
Comments
Post a Comment