Skip to content

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

Merged
zyzhu merged 3 commits intofslaborg:masterfrom
kMutagene:master
Jul 6, 2021
Merged

Add util, extension and test to read a frame from a CSV string#530
zyzhu merged 3 commits intofslaborg:masterfrom
kMutagene:master

Conversation

@kMutagene
Copy link
Copy Markdown
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
Copy Markdown
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