-
Notifications
You must be signed in to change notification settings - Fork 152
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
Append to CSV #1612
Comments
Here is somewhat of a hack that @anders-wind came up with. I haven't tested this exact code, but it creates a wrapping buffer that can be passed to Glaze to trick Glaze into appending data starting at the template <typename InnerBufferT>
struct AppendStringBuffer
{
InnerBufferT& buffer;
size_t offset {0};
using reference = char&;
constexpr auto* data()
{
return buffer.data() + offset;
}
constexpr const auto* data() const
{
return buffer.data() + offset;
}
constexpr auto operator[](size_t index) -> char&
{
return buffer[this->offset + index];
}
constexpr auto begin()
{
return buffer.begin() + static_cast<int64_t>(this->offset);
}
constexpr auto end()
{
return buffer.end();
}
constexpr auto resize(size_t val) -> void
{
buffer.resize(this->offset + val);
}
constexpr auto size() const -> size_t
{
return buffer.size() - this->offset;
}
[[nodiscard]]
constexpr auto empty() const -> bool
{
return this->size() == 0;
}
}; |
Yes we are using the above in production and then
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a good way to append to a CSV buffer?
I see this issue tangentially mentioned in #1019 but it's not clear if this is implemented yet.
For now, I could write my CSV to a string buffer and append from the buffer to the file system manually. Not sure if that is any faster than just writing the entire file repeatedly in my use case.
The text was updated successfully, but these errors were encountered: