How to read a csv file on angular2 line by line

I am programming an application in angular2 that reads a csv file with a simply input in html:

<input type='file' name='userFile' id='file' >

I can access to the file at the component.ts:

ngOnInit() {

   var input = (<HTMLInputElement>document.getElementById("file"));
   input.addEventListener("change", function(event) {
      var files = input.files;
      var len = files.length;

         if (len) {
          console.log("Filename: " + files[0].name);
          console.log("Type: " + files[0].type);
          console.log("Size: " + files[0].size + " bytes");
    
         }

      }, false);

}

How can I read cell by cell a csv file uploaded using typescript, JavaScript or jQuery? (and which is the best way to do it).

67 thoughts on “How to read a csv file on angular2 line by line”

  1. Pingback: keto burger buns
  2. Hey there! I know this is kind of off topic but I
    was wondering which blog platform are you using for this website?
    I’m getting tired of WordPress because I’ve had issues with hackers and I’m
    looking at options for another platform. I would be awesome if you could point me in the direction of a
    good platform.

    Reply
  3. Very nice post. I just stumbled upon your weblog and wished to say that
    I’ve truly enjoyed browsing your blog posts. In any
    case I will be subscribing to your rss feed and I hope you write again very
    soon!

    Reply
  4. Hi there, just became alert to your blog through Google, and
    found that it’s really informative. I’m going to watch out for
    brussels. I’ll be grateful if you continue this in future.
    Lots of people will be benefited from your writing. Cheers!

    Reply
  5. Hiya! Quick question that’s totally off topic. Do you know how to make your
    site mobile friendly? My site looks weird when browsing from
    my iphone4. I’m trying to find a theme or plugin that might be
    able to resolve this problem. If you have any recommendations, please share.

    Many thanks!

    Reply
  6. Hello there, I found your web site via Google while searching for a
    comparable subject, your site came up, it seems to be good.
    I have bookmarked it in my google bookmarks.

    Hi there, just became alert to your weblog through Google,
    and located that it is truly informative. I am going to watch out for brussels.
    I will appreciate if you continue this in future. A lot of people shall be benefited out of your writing.
    Cheers! scoliosis surgery https://0401mm.tumblr.com/ scoliosis
    surgery

    Reply
  7. First off I would like to say great blog! I had
    a quick question in which I’d like to ask if
    you don’t mind. I was interested to find out how you center yourself and clear your thoughts prior to writing.
    I’ve had trouble clearing my mind in getting my ideas
    out. I do take pleasure in writing but it just seems like the first 10 to 15 minutes
    tend to be lost simply just trying to figure out how to begin. Any suggestions or
    tips? Thank you! ps4 https://bit.ly/3nkdKIi ps4 games

    Reply

Leave a Comment