开发者

How to parse a .csv file that is local to my system in a HTML5 document?

开发者 https://www.devze.com 2023-03-25 15:50 出处:网络
I need to parse a .csv file and perform some operations on the content of the .csv file in my HTML5 document using Java script. The file that has to be parsed is local, present 开发者_StackOverflow社区

I need to parse a .csv file and perform some operations on the content of the .csv file in my HTML5 document using Java script. The file that has to be parsed is local, present 开发者_StackOverflow社区in my C drive. I would like to hard code the location of the file to be parsed. Can you provide some example using any API to achieve this ?


The first thing to do is to read the file into memory and that can be done using javascript and the HTML5 File API, however you can only read a file chosen by the user.


So, as it was mentioned, at this time you are only able to allow the user to choose the file location with the File API. However, there is also a File-System API which could assist in capturing more desired functionality. You could have the file downloaded from a server or even just stored once after obtaining via user in the file-system API. Pending on browser implementation, the browser stores the file in App-data under a new naming convection. At least this way the user would not have to re-select the file every time.

Depending on when you read this you can find what browsers support the specked feature via caniuser.com.

0

精彩评论

暂无评论...
验证码 换一张
取 消