正如其他人所說,除非您可以獲得原始數據以在適當的區域中包含換行符,否則下一個最好的辦法是獲取鍵名稱列表。
我假設60K其他行與您提供的一個樣本行具有相同的關鍵名稱?如果是這樣,如果有人不能提供你的列表,然後手動(不是編程)手動識別鍵名似乎是唯一的方法。
我自己試了一下。這似乎不太難做(最多幾分鐘),但可能仍需要有專業人士來確認關鍵列表是否正確。
一旦你的列表中,那麼你可以通過按鍵分開,然後將它們重新組合成一個新的列表:
mc_gross=22.99
invoice=ff1ca57d9fa80cf93e6b300dd7f063e1
protection_eligibility=Ineligible
address_status=confirmed
payer_id=SGA8X3TX9HCVY
tax=0.00
address_street=155 5th ave se
payment_date=16:08:28 Nov 15, 2010 PST
payment_status=Completed
charset=windows-1252
address_zip=98045
first_name=jackob
mc_fee=1.08
address_country_code=US
address_name=john martin
notify_version=3.0
custom=ff1ca5asdf7d9fa80cf93e6b300dd7f063e1
payer_status=unverified
[email protected]
address_country=United States
address_city=north bend
quantity=1
verify_sign=AZussRXZRkuk7frhfirfxxTkj0BDJGA2dJF3eF263eEsjLixS.xRxCzfaYL
[email protected]
txn_id=4DU53818WJ271531M
payment_type=instant
last_name=Martin
address_state=WA
[email protected]
payment_fee=1.08
receiver_id=QG8JPB4RZJGG4
txn_type=web_accept
item_name=Some item of consequenceSpecifie
mc_currency=USD
item_number=G10W151
residence_country=US
handling_amount=0.00
transaction_subject=ff1ca57d9fad80cf93e6b300dd7f063e1
payment_gross=22.99
shipping=0.00
您:
string rawData =
"mc_gross=22.99invoice=ff1ca57d9fa80cf93e6b300dd7f063e1protection_eligibility=Ineligibleaddress_status=confirmedpayer_id=SGA8X3TX9HCVYtax=0.00address_street=155 5th ave sepayment_date=16:08:28 Nov 15, 2010 PSTpayment_status=Completedcharset=windows-1252address_zip=98045first_name=jackobmc_fee=1.08address_country_code=USaddress_name=john martinnotify_version=3.0custom=ff1ca5asdf7d[email protected]hotmail.comaddress_country=United Statesaddress_city=north bendquantity=1verify_sign=AZussRXZRk[email protected]gmail.comtxn_id=4DU53818WJ271531Mpayment_type[email protected]hotmail.compayment_fee=1.08receiver_id=QG8JPB4RZJGG4txn_type=web_acceptitem_name=Some item of consequenceSpecifiemc_currency=USDitem_number=G10W151residence_country=UShandling_amount=0.00transaction_subject=ff1ca57d9fad80cf93e6b300dd7f063e1payment_gross=22.99shipping=0.00";
string[] keys = {
"mc_gross", "invoice", "protection_eligibility", "address_status", "payer_id", "tax",
"address_street", "payment_date", "payment_status", "charset", "address_zip",
"first_name", "mc_fee", "address_country_code", "address_name", "notify_version",
"custom", "payer_status", "business", "address_country", "address_city", "quantity",
"verify_sign", "payer_email", "txn_id", "payment_type", "last_name", "address_state",
"receiver_email", "payment_fee", "receiver_id", "txn_type", "item_name",
"mc_currency", "item_number", "residence_country", "handling_amount",
"transaction_subject", "payment_gross", "shipping"
};
string[] values = rawData.Split(keys, StringSplitOptions.RemoveEmptyEntries);
IEnumerable<string> parsedList = keys.Zip(values, (key, value) => key + value);
foreach (string item in parsedList)
{
Console.WriteLine(item);
}
這將輸出以這種格式的數據可以通過用等號(「=」)分割每個項目來進一步解析列表,或者將原始數據串替換爲現在包含缺失換行符的數據串:
string newData = parsedList.Aggregate((data, next) => data + Environment.NewLine + next);
哇。他們在想什麼? – BoltClock 2011-05-09 04:51:12
與創建這個的人一起檢查,肯定有什麼問題。你確定每個鍵/值對之間沒有CR/LF嗎? – 2011-05-09 04:52:24
所以這是一個名稱/值對列表,但沒有任何種類的分隔符之間?你有回到給你這個人的選擇,並問:1)如果他們可以提供一個分隔符和2)他們創造這個時吸菸是什麼。 – DXM 2011-05-09 04:53:36