views:

42

answers:

2

I have a contact manager program and I would like to offer the feature to import csv files. The problem is that different data sources order the fields in different ways. I thought of programming an interface for the user to tell it the field order and how to handle exceptions.

Here is an example line in one of many possible field orders: "ID#","Name","Rank","Address1","Address2","City","State","Country","Zip","Phone#","Email","Join Date","Sponsor ID","Sponsor Name" "Z1234","Call, Anson","STU","1234 E. 6578 S.","","Somecity","TX","United States","012345","000-000-0000","[email protected]","5/24/2010","z12343","Quantum Independence"

Notice that in one data field "Name" there is a comma to separate last name and first name and in another there is not.

My plan is to have a line for each field (ie ID, Name, City etc.) and a statement "import to" and list box with options like: Don't Import, Business>Join Date, First Name, Zip and the program recognizes those as properties of an object...

I'd also like the user to be able to record preset field orders so they can re-use them for csv files from the same download source.

Then I also need it to check if a record all ready exists (is there a record for Anson Call all ready?) and allow the user to tell it what to do if there is a record (ie mailing address may have changes, so if that field is filled overwrite it, or this mailing address is invalid, leave the current data untouched for this person, overwrite the rest).

While I'm capable of coding this...i'm not very excited about it and I'm wondering if there's a tool or set of tools out there to all ready perform most of this functionality...

I hope this makes sense...

+1  A: 

Is there a header row?

usually in CSV files, the first line is the header.

If so you could use the header line to determine the order, just have a list of column names, and only prompt the user if a column name does not match.(this could then be auto added into the predefined list).

EDIT:

even if a header does not exist, its simple enough to add one. The file can be manually edited. Alternatively in your program let the user define it (from your predefined list)

Darknight
Yes, but not all headers are the same, ie Address 1, mailing adresss, caps no caps...(but there will usually be a header row...the point is that they are variable though....I'm not saying I couldn't do it I was just wondering how much of it all ready has been done...
Assimilater
yes, thats why I said you could use a predefined list, eg 'Address 1', 'mailing address' etc, would all map to the same field. Any columns that do not match this list, the user gets prompted, you then simply add this to the list for that column.
Darknight
Ok, I see what you're saying, but there still might be cases where the current data is different than the imported data and the user may or may not want to overwrite current data for various reasons. I've noticed a lot of csv tools and wasn't sure any of them would really help me but was curious if there was something to handle all these exceptions (there are a lot of them....).
Assimilater
A: 

I can't find any tools all ready out there and no one has replied otherwise, so for the sake of leaving a question answered until otherwise notified the answer is: no.

Assimilater