-3

I'm getting this response from amazon, it just string. The first values are the titles and the other values are the values.

The Response is :

order-id order-item-id purchase-date payments-date buyer-email buyer-name 103-26010-55904 394929210114 2011-02-09T02:46:57-08:00 2011-02-09T02:46:57-08:00 Joe@marketplace.amazon.com Joe Customer

I don't find any approach to parse it to json or datatable or excel Please Advise.

israel altar
  • 1,768
  • 1
  • 16
  • 24
avnic
  • 3,241
  • 8
  • 37
  • 46
  • 1
    Is the number of fields fixed? Do you need the field names? If you answered "yes" and "no", respectively, to those question it's very simple: Discard the titles, and split the actual data on whitespace. – Some programmer dude Jul 06 '15 at 08:24
  • 1
    yes the number of the fields are fixed, but i can't split with whitespace because for example the name field "Joe Customer" – avnic Jul 06 '15 at 08:27
  • 3
    since you don't have spaces in the other fields, I don't see why you can't split by space and then group everything after the e-mail – greenfeet Jul 06 '15 at 08:31

1 Answers1

0

Assuming buyer-name is the only field with spaces you can do:

var results = data.Split(new string[] {" "}, StringSplitOptions.None).Skip(6).ToArray();
var orderid = results[0];
var itemid = results[1];
var pudate = results[2];
var pydate = results[3];
var email = results[4];
var name = string.Join(" ", results.Skip(5).Take(results.Length - 5).ToArray());
Kevin
  • 2,281
  • 1
  • 14
  • 16