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

Add util, extension and test to read a frame from a CSV string #530

Merged
merged 3 commits into from
Jul 6, 2021
Merged

Add util, extension and test to read a frame from a CSV string #530

merged 3 commits into from
Jul 6, 2021

Conversation

kMutagene
Copy link
Member

This PR adds a Frame extension that can read CSV from a string.

Currently, two extra steps are needed to do that: reading the bytes from the string, and passing a MemoryStream based on that to Frame.ReadCsv:

let byteArray = Encoding.UTF8.GetBytes(dataString)
use stream = new MemoryStream(byteArray)
Frame.ReadCsv(stream,true,separators=",")

Why add this?

While this saves 'only' 2 LOC in scripts, this is a common operation when getting data via HTTP requests and therefore justifies the addition IMHO. This happens often when analyzing data from online sources. Examples where i use it can be seen in the Plotly.NET docs

I added a test based on the tests already implemented. If i should add more or change something, please let m know ;)

@zyzhu zyzhu merged commit 282df8d into fslaborg:master Jul 6, 2021
@zyzhu
Copy link
Contributor

zyzhu commented Jul 6, 2021

Thanks for the addition. I've released 2.4.0 on nuget.

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

Successfully merging this pull request may close these issues.

2 participants