Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
Single CSV column is using multiple columns in HTML table

After a long journey to figure out how to load .csv files into a table I've run into another issue. One of the columns in my .csv file is splitting into other columns in my HTML table.

Part of the issue was with the file itself, where the content was actually split into other columns. After fixing everything (I left one on purpose), I'm still facing the same problem. It doesn't seem to be a character limit issue as they split after random words each time.

enter image description here

enter image description here

The very first entry in the .csv file is an easy example of what's going on. It also isn't everything in that column. The table is being read in through ajax and jQuery with the following code:


$(document).ready(function(){
    $('#file').click(function(){
     $.ajax({
      url:"014 - Dark Beginning 1 2004.csv",
      dataType:"text",
      success:function(data)
      {
       var card_data = data.split(/\r?\n|\r/);
       var table_data = '<table class="table table-bordered table-striped">';
       for(var count = 0; count<card_data.length; count++)
       {
        var cell_data = card_data[count].split(",");
        table_data += '<tr>';
        for(var cell_count=0; cell_count<cell_data.length; cell_count++){
         if(count === 0){
          table_data += '<th>'+cell_data[cell_count]+'</th>';}
            else{
          table_data += '<td>'+cell_data[cell_count]+'</td>';}
        }
        table_data += '</tr>';
       }
       table_data += '</table>';
       $('#card_table').html(table_data);
      }
     });
    });
    
   });

Is this some limit tables innately have or some other issue entirely? I have very minimally changed the CSS for the table solely to make it easier for me to look at for when I get to organizing the page layout.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since you're just splitting the comma string values by comma (,) you're splitting the strings in your descriptions values as well. In a csv file, values that might contain the separator (, in this case) or other special characters are wrapped by quotes "", in your case in the descriptions.

You must not account for any comma that might reside inside a quoted string, as everything written inside account for a single value of a column row.

I would suggest using a library, such as csv-parser to handle this kind of parsing, as those kind of tasks might take a lot of details into account that you might not want to be troubled with.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!