Closed felswa closed 1 year ago
Works for me. Both when initialising from an URL or a string.
let sampleCSVTest = """
"Date","Action","Symbol","Description","Quantity","Price","Fees & Comm","Amount"
"08/22/2023","Buy","912797GM3","US TREASURY BILL24U S T BILL DUE 02/08/24","5,000","$97.5285","","-$4876.42"
"""
do {
csv = try CSV<Named>(string: sampleCSVTest)
} catch {
XCTAssert(false, "Could not create CSV instance from: \(sampleCSVTest)")
}
for (index, row) in csv.rows.enumerated() {
print(row)
}
Executed 43 tests, with 0 failures (0 unexpected) in 0.412 (0.417) seconds
["Date": "08/22/2023", "Fees & Comm": "", "Symbol": "912797GM3", "Amount": "-$4876.42", "Quantity": "5,000", "Price": "$97.5285", "Description": "US TREASURY BILL24U S T BILL DUE 02/08/24", "Action": "Buy"]
Could you perhaps link to a sample CSV file?
Apologies. It does work. Issue was when Excel re-saves a CSV file the quotations were dropped.
I have a 3rd part file as below where it has a comma with "5,000" which I do not want to be parsed into 2 separates items but SwiftCSV seems to do this. Is there any way to fix this? Thanks.
result is: