• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Merging rows with same ID together with dynamic headers with CSV

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic