pola-rs / js-polars Goto Github PK
View Code? Open in Web Editor NEWJS bindings to polars
License: MIT License
JS bindings to polars
License: MIT License
node -v
v16.14.0
yarn add @pola-rs/browser
package.json
{
"dependencies": {
"@pola-rs/browser": "^0.0.1-alpha"
},
"type": "module",
"scripts": {
"start": "node index.js"
}
}
index.js
import * as pl from "@pola-rs/browser"
const filepath = "https://raw.githubusercontent.com/pola-rs/polars/master/examples/datasets/foods2.csv"
let df = await pl.read_csv(filepath)
let lf = df.lazy();
df = await lf.collect()
console.table(df.head(10).to_records());
yarn start
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'C:\PolarsTest\node_modules\@pola-rs\browser\' imported from C:\PolarsTest\index.js
←[90m at new NodeError (node:internal/errors:371:5)←[39m
←[90m at legacyMainResolve (node:internal/modules/esm/resolve:336:9)←[39m
←[90m at packageResolve (node:internal/modules/esm/resolve:917:14)←[39m
←[90m at moduleResolve (node:internal/modules/esm/resolve:976:18)←[39m
←[90m at defaultResolve (node:internal/modules/esm/resolve:1078:11)←[39m
←[90m at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)←[39m
←[90m at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)←[39m
←[90m at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)←[39m
←[90m at link (node:internal/modules/esm/module_job:78:36)←[39m {
code: ←[32m'ERR_MODULE_NOT_FOUND'←[39m
@universalmind303 I fail to import browser side, via a script invoked in index.html.
Steps to reproduce:
mkdir jspolars
cd jspolars
$ yarn add @pola-rs/browser
yarn add v1.22.21
info No lockfile found.
(node:63701) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @pola-rs/[email protected]
info All dependencies
└─ @pola-rs/[email protected]
✨ Done in 1.78s.
./index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>pola-rs/browser</title>
</head>
<body>
<div id="output"></div>
<script type="module" src="./script.js"></script>
</body>
</html>
./script.js
import * as pl from "./node_modules/@pola-rs/browser"
let filepath = "https://raw.githubusercontent.com/pola-rs/polars/master/examples/datasets/foods2.csv"
let response = await fetch(filepath);
let responseTEXT = await response.text();
let df = await pl.readCSV(responseTEXT);
console.table(df)
./start-http-server-8119.sh
python -m http.server --bind 127.0.0.1 8119
Start the server:
. start-http-server-8119.sh
Serving HTTP on 127.0.0.1 port 8119 (http://127.0.0.1:8119/) ...
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET /script.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET /node_modules/@pola-rs/browser/ HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET /favicon.ico HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /script.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /node_modules/@pola-rs/browser HTTP/1.1" 301 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /node_modules/@pola-rs/browser/ HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /favicon.ico HTTP/1.1" 200 -
Using import * as pl from "@pola-rs/browser"
fails:
console.log:
```
localhost/:1 Uncaught TypeError: Failed to resolve module specifier "@pola-rs/browser".
Using `import * from "./node_modules/@pola-rs/browser"` fails:
console.log:
browser/:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
This just gives the directory listing.
No joy importing browser/browser.js either.
How should I do this? I'd like to integrate polars into a browser-side library suite. It does not have to be perfect at this juncture, for p.o.c., but hoping of course for further development.
thanks, George
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.