Golang encoding/csv: Difference between revisions

From wikinotes
(Created page with "Go's builtin module for encoding/decoding csv files. {{ NOTE | go's builtin csv module does not conform to it's encoding interface. }} = Serializing = <blockquote> </blockquote><!-- Serializing --> = Deserializing = <blockquote> </blockquote><!-- Deserializing -->")
 
Line 12: Line 12:
= Deserializing =
= Deserializing =
<blockquote>
<blockquote>
 
<syntaxhighlight lang="go">
data := `1,2,3
        4,5,6`
reader := csv.NewReader(strings.NewReader(data))
records, _ := reader.ReadAll()
fmt.Println(records[0][0]) // 1
</syntaxhighlight>
</blockquote><!-- Deserializing -->
</blockquote><!-- Deserializing -->

Revision as of 00:48, 26 June 2022

Go's builtin module for encoding/decoding csv files.

NOTE:

go's builtin csv module does not conform to it's encoding interface.


Serializing

Deserializing

data := `1,2,3
         4,5,6`
reader := csv.NewReader(strings.NewReader(data))
records, _ := reader.ReadAll()
fmt.Println(records[0][0]) // 1