Bulk import CSV with TAB delimiters

SOLVED
Highlighted
Occasional Contributor

Bulk import CSV with TAB delimiters

Hi,

I'm using a C# program with the .NET SDK to bulk import our tab delimited CSV data.  I'm getting a error stating that the file is not the correct format.  The program throws an exception in the following API call.  I've imported the same CSV file with the Constant Contact website with no problems.  Any ideas as to what is going wrong?

 

Thanks,

Tony Green

Snohomish Flying Service

 

 

public Activity AddContactstMultipartActivity(string accessToken, string apiKey, string fileName, byte[] fileContent, IList<string> lists)
        {
            Activity activity = null;
            string url = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.AddContactsActivity);
            byte[] data = MultipartBuilder.CreateMultipartContent(fileName, fileContent, lists);
            CUrlResponse response = RestClient.PostMultipart(url, accessToken, apiKey, data);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

 

 

static int Main(string[] args)
{
    ConstantContact constantContact = new ConstantContact(APIKEY, ACCESSTOKEN);
 
    string filename = FILEPATH + FILENAME;
    FileInfo fi = new FileInfo(filename);
 
    // Add XLS file contacts to "TESTING" list - 1660588414
    byte[] contents;
    using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
    {
        contents = new byte[fs.Length - 1];
        fs.Read(contents, 0, contents.Length);
        //string data = Encoding.Default.GetString(contents);
    }
 
    Activity activity = constantContact.AddContactsMultipartActivity(fi.Name, contents, new List<string> { TESTINGLIST });
    if (activity.Status == null)
    {
        Console.WriteLine("Contact Count: " + activity.ContactCount);
        Console.WriteLine("Error Count: " + activity.ErrorCount);
        Console.WriteLine();
    }
    else
    {
        Console.WriteLine("Status: " + activity.Status);
        Console.WriteLine(activity.Errors.ToString());
        Console.WriteLine();
    }
Tags (4)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Bulk import CSV with TAB delimiters

Checked our code and the API currently does not support tab seperated values.  We are investigating if our new contact management system still supports TSV and, if so, we will look into adding support for that format going forward.  This is not something we would likely add in the short term.

 

Our recommendation is to use the CSV file format instead.  Will update when we find out if TSV formats should be expected to work going forward.

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

3 REPLIES 3
Highlighted
Moderator

Re: Bulk import CSV with TAB delimiters

Tony/Heather,

 

The bulk import (multipart) endpoint supports files with the following formats:

  • txt
  • csv
  • xls
  • xlsx

You said you're working with a tab-delimited CSV file. I believe a file is either tab delimited, or comma separated, but not both. 

 

The full documentation is available here.

Rich Marcucella
Sr. Technical Writer, Content Developer
Web Services Team
http://developer.constantcontact.com
Highlighted
Occasional Contributor

Re: Bulk import CSV with TAB delimiters

Yes, precisely...my file is TAB delimited and the file extension is .CSV.  It imported just fine in the CC website.

Highlighted
Moderator

Re: Bulk import CSV with TAB delimiters

Checked our code and the API currently does not support tab seperated values.  We are investigating if our new contact management system still supports TSV and, if so, we will look into adding support for that format going forward.  This is not something we would likely add in the short term.

 

Our recommendation is to use the CSV file format instead.  Will update when we find out if TSV formats should be expected to work going forward.

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

Developer Portal

View API documentation, code samples, get your API key.

Constant Contact would like to hear from you

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured