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).

128 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.

  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

  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!

  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!

  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 scoliosis

  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 ps4 games

  8. Please let me know if you’re looking for a article writer
    for your weblog. You have some really great posts and I think I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some
    material for your blog in exchange for a link back to mine.
    Please blast me an e-mail if interested.
    Thank you!

  9. You’ve made some really good points there. I looked on the web for additional information about the issue and found most people will go along with your views on this site.