-
Notifications
You must be signed in to change notification settings - Fork 268
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
Cannot parse from a stream in the browser #443
Comments
you can also look at the demo folders. |
Thanks very much for the rapid response. Unfortunately, this doesn't seem to fix the error. Here's what I did:
But I still get the same error:
Once I've figured out the underlying problem here, I'd also like to use a CDN if possible. Would you be open to a PR on the documentation suggesting how a CDN can be used? |
I noticed your URL referencing I just tried the following commands successfully. mkdir csv-443
cd csv-443
# Download the source code
npm install csv-parse
# Create an html file
cat <<'HTML' >index.html
<script type="module">
import { parse } from '/node_modules/csv-parse/dist/esm/sync.js';
console.log('ok1', parse)
const data = parse("a,b,c\n1,2,3\n4,5,6", { columns: true });
document.body.innerHTML = `<pre>${ JSON.stringify(data, 0, 2) }</pre>`
</script>
HTML
# Start an HTML server
npm install http-server
npx http-server -p 3000 . |
The URL is a CDN reference - I put that in there because I want the page I'm creating to be standalone, rather than hosted alongside some node modules. It's not that I can't import the module at all - the example you've sent works for me too. The problem is that I can't use it in a stream. So if you do the same set of commands, but instead create this code in the
Then it gives the error:
I can also use the
|
Describe the bug
I want to allow a user to upload a gzipped csv file and parse it in a stream (using
pipeThrough
/pipeTo
). This works in Node, but not in the browser, where I get:Line 52 is the
pipeTo
line from the example below, so it seems to think that theparse
object is not aWritableStream
.To Reproduce
Dump the code below into a file, open it in a browser and then try uploading a
.tsv.gz
file. I tested in Chrome and Firefox. The same code works in Node, although you have to swappipeThrough
andpipeTo
forpipe
. I'll admit that I find the differences between Node and the browser for streaming a bit confusing so I may have made some obvious error here.** Additional Context **
I wonder if this issue is related, although I'm not trying to parse the complex CSVs listed in that issue.
I also have a similar issue raised for Papaparse.
The text was updated successfully, but these errors were encountered: