Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate designs for appending and exporting rows #109

Open
lardieri opened this issue Aug 27, 2022 · 0 comments
Open

Investigate designs for appending and exporting rows #109

lardieri opened this issue Aug 27, 2022 · 0 comments

Comments

@lardieri
Copy link
Contributor

lardieri commented Aug 27, 2022

On 2022-08-25, @DivineDominion wrote:

The extraction of shared serialization logic makes sense, too. It introduces potential variance between the CSV's data and the serializer, because the serializer can be ab-used independently (see below). But in principle, it's a good idea IMHO!

However, would you have any concerns about making Serializer be public? It might help me with a project I'm working on.

(Actually, what I really want is to add additional rows to an existing file. I'm still working out the design, so it's not clear yet whether I should append rows to my DataView and serialize the whole thing, or go directly to the file APIs to write out only the new rows.)

In my Mac app TableFlip, I import from CSV to an internal tabular data structure, and export that to various formats.

I could see how the CSV type could be useful as a mutable table representation, but that's a bit out of scope for CSV -- that's a more generic "table" or a "tabular". (We could add that, too, but that needs more discussion I think.)

Producing CSV export data here does still make total sense, though, e.g. to quickly convert delimiters. Mutating the CSV output a bit sounds like a CSV-centric use case during export, too. It does make sense.

In the context of the SwiftCSV module, the name Serializer fits well. But when it becomes public API, should we call it CSVSerializer instead? Then again SwiftCSV.Serializer can be used to disambiguate, too. I have no strong opinion on this.

When we make Serializer public, we need handle more inconsistent data: it used to be the CSV views's job to assemble the serializable content in a way that made sense to the CSV view.

But if the serializer is extracted, and esp. if it's public, we can't make any assumptions.

We'd need

  • unit tests for all public functions, e.g. to demonstrate that the enquoting of cell contents works as expected;
  • handle non-rectangular data, i.e.:
    • what happens if some rows have less/more elements than others?
    • what happens if the header cell count is x, but a row's element count is >x?
    • I tend towards making header.count canonical; cut off row cells at offsets beyond header.count, and if rows are too short, fill with empty cells -- so that in effect, each row has the same amount of delimiters

This is a bit of extra work. Do you think that's worth it for your use case? If so, let's check out how to design this properly 💪

Originally posted by @DivineDominion in #107 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant