Skip to content

Instantly share code, notes, and snippets.

document.getElementById("summary-output").innerText = summary_text
pyodide.runPython(`
import pandas as pd
from io import StringIO
from js import document
# Load CSV
df = pd.read_csv(StringIO(csv_text))
# Show first rows
document.getElementById("data-output").innerText = df.head().to_string()
pyodide.runPython(`
import pandas as pd
from io import StringIO
from js import document
# Load CSV
df = pd.read_csv(StringIO(csv_text))
# Show first rows
document.getElementById("data-output").innerText = df.head().to_string()
pyodide.globals.set("csv_text", text);
const pyodide = await loadPyodide();
await pyodide.loadPackage(["numpy", "pandas"]);
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Python CSV Analysis in the Browser</title>
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
<style>
body {
import * as WasmModule from './pkg/index.js';
// Expose the function globally for the HTML button's onclick handler for simplicity
window.doMath = async () => {
// The Wasm module handles instantiation when first imported/awaited
const { add, greet } = await WasmModule.instantiate(fetch('./pkg/release.wasm'));
const num1 = parseInt(document.getElementById('num1').value);
const num2 = parseInt(document.getElementById('num2').value);
<!DOCTYPE html>
<html>
<body>
<h2>Wasm 2025 Component Demo</h2>
<input type="number" id="num1" value="40">
<input type"number" id="num2" value="2">
<button onclick="doMath()">Add with Wasm</button>
<p id="result">Result will appear here.</p>
<!-- Load our JS entry point as a module -->