Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
The sample vega-lite code below is getting data from an url.
Instead, I would like it to read the .csv from my local file system.
How to do that?
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "mydata.csv"},
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
}
}
Thanks.
Hi @jkfe ,
Depending on the information you provide, you can make the local .csv file accessible via a URL by making it available locally or via a Web server. You can follow the steps below:
1. If you are using Python version 3.x, navigate to the directory containing the .csv file on the command line and run the following command:
python -m http.server
2. Ensure that the web pages are served from the same local server to avoid cross-domain issues. You can modify the Vega-Lite specification to use the URL of the data source:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "http://localhost:8000/mydata.csv"},
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
}
}
Best Regards,
Ada Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for answer.
That would require a local web server as I understand. Wouldn't like to have that. Want to access a file directly from the file system.
@jkfe , Try this in blank query in power query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY5BDoIwEEWvQhqXCis3rL0FZVHLCKOlrXRoJIa7W9oIGrqa/vz3ZqqKvbnO4uPs4GQHveCsDJ+OyLqyKDy0Im+RuvGaoylSJaYnhQSFP+d3ZzRnx03UCIqW1b2EXqgRXJJL5y+xk30b8w/ei+GRego1/JlBS9Ogbnf2V0rYDUE1CQ5XLHCYaLKQMoLemkEozraFCz7tcTug3PHPUWhCEoQ+JPN6fRpmVtcf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Parsed JSON" = Table.TransformColumns(#"Changed Type",{},Json.Document),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Parsed JSON", "Column1", {"$schema", "data", "mark", "encoding"}, {"Column1.$schema", "Column1.data", "Column1.mark", "Column1.encoding"}),
#"Expanded Column1.data" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.data", {"values"}, {"Column1.data.values"}),
#"Added Custom" = Table.AddColumn(#"Expanded Column1.data", "Custom", each Table.Unpivot( Table.FromRecords({[Column1.encoding]}), {"x","y"}, "attribute", "value")),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"attribute", "value"}, {"Custom.attribute", "Custom.value"}),
#"Expanded Custom.value" = Table.ExpandRecordColumn(#"Expanded Custom", "Custom.value", {"field", "type"}, {"Custom.value.field", "Custom.value.type"})
in
#"Expanded Custom.value"
Sorry. Didn't understand the code. Appreciate if you can explain. For instance, where to inform the file name/path.
User | Count |
---|---|
64 | |
59 | |
47 | |
33 | |
32 |
User | Count |
---|---|
84 | |
75 | |
56 | |
50 | |
44 |