简体   繁体   English

使用JavaScript获取CSV列的名称

[英]Getting CSV Columns' name using JavaScript

I must upload large files (+1GB) in CSV format. 我必须上传CSV格式的大文件(+ 1GB)。 I must check the column names, and I want to do it before upload process. 我必须检查列名,并且我想在上传过程之前执行此操作。 So, I am trying to read the CSV using JavaScript, following 因此,我尝试使用JavaScript读取CSV,如下

http://www.html5rocks.com/en/tutorials/file/dndfiles/ http://www.html5rocks.com/en/tutorials/file/dndfiles/

and

https://developer.mozilla.org/en-US/docs/Web/API/FileReader.readAsBinaryString https://developer.mozilla.org/en-US/docs/Web/API/FileReader.readAsBinaryString

It work! 这行得通! But I have to read the complete file, and believe me, the files are too large. 但是我必须阅读完整的文件,并相信我,文件太大。

My question is: How can I get the CSV columns' name using JavaScript, without reading the entire file? 我的问题是:如何在不读取整个文件的情况下使用JavaScript获取CSV列的名称?

You can access all kinds of data about a file without passing it to a FileReader . 您可以访问有关文件的各种数据,而无需将其传递给FileReader You can get the size of a file by checking file.size . 您可以通过检查file.size来获取文件的大小。

Check the documentation for File and Blob ( File inherits Blob ) to see what else is available to you. 查看FileBlob的文档( File继承了Blob ),以了解其他可用内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM