From 1d0f5fa9ff9f880e8dcc8a549f2da77600d54b57 Mon Sep 17 00:00:00 2001 From: Fumiya Tanaka Date: Thu, 2 Feb 2023 00:28:11 +0900 Subject: [PATCH] Update README.md (#39) --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3ab796a..7e0a012 100644 --- a/README.md +++ b/README.md @@ -114,14 +114,14 @@ A helper library to generate `Csv` in Csv2Img library. ## How to use -1. Define custom type which conform to `CsvComposition`. +1. Define custom type that conforms to `CsvComposition`. ```swift import Foundation import Csv2Img -public struct ExampleComposition: CsvComposition { +public struct CsvCompositionExample: CsvComposition { @CsvRows(column: "age") public var ages: [String] @@ -135,12 +135,21 @@ public struct ExampleComposition: CsvComposition { 2. Build `Csv` ```swift -let composition: ExampleComposition = .init() +let composition: CsvCompositionExample = .init() composition.ages.append(contentsOf: ["98", "99", "100"]) composition.names.append(contentsOf: ["Yamada", "Tanaka", "Sato"]) let csv = try! composition.build() ``` +or you can write different way like the below. + +```swift +let yamada = Csv.Row(index: 0, values: ["98", "Yamada"]) +let tanaka = Csv.Row(index: 1, values: ["99", "Tanaka"]) +let sato = Csv.Row(index: 2, values: ["100", "Sato"]) +let csv = try! CsvCompositionParser.parse(type: CsvCompositionExample.self, rows: [yamada, tanaka, sato,]) +``` + | Result | | ------ | |スクリーンショット 2022-08-26 12 54 22|