我正在尝试重新排列以下示例数据的列顺序,
USI,CFG LEI,Counterparty LEI,UPI,Product Class,Execution venue,MTM,Currency 1,Currency 2,Notional amount 1,Notional amount 2,Exchange rate,Delivery type,Settlement or expiration date,Execution Venue LEI,Indication of collateralization,Trade ID,CounterParty full Name,Start Date,Deal Code,Settlement Currency,Valuation Fixing Date,Trade Date and timestamp,CIS Code (Internal),Trade Description,UTI,Is CFG Reporting Party?,Contract type,UTI Leg 2 ,Counterparty purchasing protection ,Counterparty selling protection ,Reference Entity ,Maturity Date ,Price ,Cap Strike ,Floor Strike ,Notional Amount ,Notional Currency ,Upfront Payment Amount ,Upfront Payment Currency ,Payment frequency of the reporting counterparty. ,Payment frequency of the non-reporting counterparty ,Day count convention ,Notional amount (leg 1) ,Notional currency (leg 1) ,Notional amount (leg 2) ,Notional currency (leg 2) ,Pay Leg Type (CFG) ,Receive Leg Type (CFG) ,Direction ,Option type ,Fixed rate ,Fixed rate 2 ,Fixed rate day count fraction ,Floating rate payment frequency ,Floating rate reset frequency ,Floating rate index name/rate period ,Floating rate Index 2 ,Buyer ,Seller ,Quantity unit ,Quantity frequency ,Total quantity ,Total Remaining Quantity ,Notional ,Settlement method ,Price unit ,Price currency ,Buyer pay index ,Buyer pay averaging method ,Seller pay index ,Seller pay averaging method ,Grade ,Option style ,Option premium ,Hours from through ,Hours from through time zone ,Days of week ,Load type
,DRMSV1Q0EKMEXLAU1P80,549300UGRJZFKLBDNB67,,FXF,OffFacility,-6573.66,EUR,USD,817785,923933.49,1.1298,Physical,4/13/2028,,Uncollateralized,2.02304E+12,AG NET LEASE RLTY FND IV Q LP,4/12/2023,B,,,12-Apr-23,AA077C7,FX FORWARD TRANSACTION,DRMSV1Q0EKMEXLAU1P80WSSFX202304120000436044681000001,Y,FX FORWARD TRANSACTION,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,DRMSV1Q0EKMEXLAU1P80,549300UGRJZFKLBDNB67,,FXF,OffFacility,-6573.66,EUR,USD,817785,923933.49,1.1298,Physical,4/13/2028,,Uncollateralized,2.02304E+12,AG NET LEASE RLTY FND IV Q LP,4/12/2023,B,,,12-Apr-23,AA077C7,FX FORWARD TRANSACTION,DRMSV1Q0EKMEXLAU1P80WSSFX202304120000436044681000001,Y,FX FORWARD TRANSACTION,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
为了实现这一点,我正在尝试下面的 shell 脚本,
#!/bin/bash
#Reordering the columns
temp_file=$(mktemp)
mlr --csv reorder -f "\"Trade ID\",\"Trade Date and timestamp\",\"CounterParty full Name\",\"CIS Code (Internal)\",\"Trade Description\",\"USI\",\"UTI\",\"UTI Leg 2\",\"CFG LEI\",\"Counterparty LEI\",\"Is CFG Reporting Party?\",\"UPI\",\"Contract type\",\"Execution venue\",\"Execution Venue LEI\",\"Counterparty purchasing protection\",\"Counterparty selling protection\",\"Reference Entity\",\"Start Date\",\"Maturity Date\",\"Price\",\"Cap Strike\",\"Floor Strike\",\"Notional Amount\",\"Notional Currency\",\"Upfront Payment Amount\",\"Upfront Payment Currency\",\"Payment frequency of the reporting counterparty.\",\"Payment frequency of the non-reporting counterparty\",\"Currency 1\",\"Currency 2\",\"Notional amount 1\",\"Notional amount 2\",\"Exchange rate\",\"Delivery type\",\"Settlement or expiration date\",\"Day count convention\",\"Notional amount (leg 1)\",\"Notional currency (leg 1)\",\"Notional amount (leg 2)\",\"Notional currency (leg 2)\",\"Pay Leg Type (CFG)\",\"Receive Leg Type (CFG)\",\"Direction\",\"Option type\",\"Fixed rate\",\"Fixed rate 2\",\"Fixed rate day count fraction\",\"Floating rate payment frequency\",\"Floating rate reset frequency\",\"Floating rate index name/rate period\",\"Floating rate Index 2\",\"Buyer\",\"Seller\",\"Quantity unit\",\"Quantity frequency\",\"Total quantity\",\"Total Remaining Quantity\",\"Notional\",\"Settlement method\",\"Price unit\",\"Price currency\",\"Buyer pay index\",\"Buyer pay averaging method\",\"Seller pay index\",\"Seller pay averaging method\",\"Grade\",\"Option style\",\"Option premium\",\"Hours from through\",\"Hours from through time zone\",\"Days of week\",\"Load type\",\"Indication of collateralization\",\"MTM\",\"Product Class\",\"Deal Code\",\"Settlement Currency\",\"Valuation Fixing Date\"" Wallstreet_Source_File.csv > "$temp_file"
mv "$temp_file" Wallstreet_Source_File.csv
执行上述 shell 脚本时出现以下错误
mlr CSV header/data length mismatch 79 != 28 at filename Wallstreet_Source_File.csv row2
我正在尝试根据脚本(mlr)中提到的顺序对列重新排序,缺少任何内容或任何其他方法来实现它。