File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Merging rows with same ID together with dynamic headers with CSV Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Merging rows with same ID together with dynamic headers with CSV" Watch "Merging rows with same ID together with dynamic headers with CSV" New topic
Author

Merging rows with same ID together with dynamic headers with CSV

Jas Get
Greenhorn

Joined: Aug 05, 2010
Posts: 2
Please Help, I just can't figure it out. A friend helped with this but could not figure it our either.

I am trying to merge CSV rows together that have the same ID number, but have different values in the fields. I receive csv files weekly that can have different header names and sizes.

For example,

Read in this CSV file:

ID NAME PHONE EMAIL
22 John 555-1111
22 John 555-2222 john@aol.com
44 Bill 555-9999 Bill@aol.com

Should return:

ID NAME PHONE EMAIL PHONE0
22 John 555-1111 john@aol.com 555-2222
44 Bill 555-9999 Bill@aol.com


But it returns:

ID NAME PHONE EMAIL PHONE0 EMAIL0
22 John 555-1111 Bill@aol.com 555-2222 john@aol.com
44 Bill 555-9999


It does work correctly when I have this file:
ID NAME PHONE EMAIL
22 John 555-1111 john@aol.com
22 John 555-2222 john@aol.com
44 Bill 555-9999 Bill@aol.com





Here is my Code:
Jas Get
Greenhorn

Joined: Aug 05, 2010
Posts: 2
This is just some simple test data. Sometimes there are 20 headers with 80,000 records so I was wondering if this is the most efficient way to process the records.

Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Merging rows with same ID together with dynamic headers with CSV