目录

CSVEncoder

Very basic support for encoding an Swift object as CSV.

Usage

let encoder = CSVEncoder()
encoder.dateEncodingStragegy = .iso8601
let data = try! encoder.encode(rows: [MyCodableThing()])

You pass the encoder a list of codable objects.

This results in a data object which is a UTF-8 string.

Each line of the string contains a value for each property of the codable object.

Headers

By default the first line of the encoded text is a header, using the names of the properties.

This can be disabled with encoder.headerEncodingStrategy = .none, or you can supply header names to the encoder manually when you create it.

You can also supply some translation settings with an optional bundle, table and/or prefix. If these are supplied, the header names are used as NSLocalizedString keys, and the resulting translated versions are written out.

Decoding

Currently only encoding is supported. Simple decoding should be quite easy for me to add however, so please open an issue if you need it.

关于
47.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号