-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1483 from bonjune/csv-schema-multiline
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -639,3 +639,36 @@ let ``InferColumnTypes shall infer empty string as Double``() = | |
let expected = "Double" | ||
let actual = types.[3].Value.InferedType.Name | ||
actual |> should equal expected | ||
|
||
let [<Literal>] manyColumnCsv = """ | ||
"001","2022-01-01 10:00:00","100.00","John S.","+1 (555) 123-4567","[email protected]","","John Smith","California","Los Angeles","123 Main St.","90001","P001","Widget A","2","25.00" | ||
"002","2022-01-02 14:30:00","50.00","Alice T.","+1 (555) 987-6543","[email protected]","Please deliver after 6pm.","Alice Thompson","New York","Brooklyn","456 Elm St.","10001","P002","Widget B","1","50.00" | ||
"003","2022-01-03 08:15:00","75.00","Bob R.","+1 (555) 555-1212","[email protected]","","Bob Robertson","Florida","Miami","789 Oak Ave.","33010","P003","Widget C","3","25.00" | ||
"004","2022-01-04 16:00:00","200.00","Jane D.","+1 (555) 555-5555","[email protected]","Please include gift receipt.","Jane Doe","Texas","Austin","321 Pine St.","78701","P004","Widget D","4","50.00" | ||
"005","2022-01-05 12:00:00","60.00","Sam G.","+1 (555) 555-1212","[email protected]","","Sam Green","California","San Francisco","987 Oak St.","94101","P005","Widget E","2","30.00" | ||
""" | ||
|
||
[<Test>] | ||
let ``Can infer from a multiline schema`` () = | ||
let csv = | ||
CsvProvider<manyColumnCsv, | ||
HasHeaders = false, | ||
Schema = "OrderNumber (string), | ||
OrderCreated (string), | ||
OrderTotal (string), | ||
FioShort (string), | ||
PhoneNumber (string), | ||
Email (string), | ||
Comment (string), | ||
FioFull (string), | ||
Region (string), | ||
Town (string), | ||
Address (string), | ||
Postindex (string), | ||
ProductId (string), | ||
ProductTitle (string), | ||
ProductQuantity (string), | ||
ProductPrice (string)">.GetSample () | ||
let firstRow = csv.Rows |> Seq.head | ||
firstRow.OrderCreated |> should equal "2022-01-01 10:00:00" | ||
|