Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:15:55+00:00 2026-06-08T08:15:55+00:00

I am trying to add an ability to allow users of a wvb app

  • 0

I am trying to add an ability to allow users of a wvb app to bulk upload data using a CSV file – everything works great except when the data includes a comma in the actual field itself.

There are lots of posts regarding this and I have read many ways of addressing it mainly by enclosing the comma in double quotes but I cannot figure out how to do this for my code.

Ultimately I cannot rely on users to do this for me at input time so I need to do it as part of the upload process before it hits the database – I tried using tab as an alternate separator but Excel seems to be very inconsistent in how it handles tab separation so I ruled that out.

(sanitiseData is a function I use throughout the site to clean all user input data)

        $handle = fopen($file_path, 'r');  
        $row_count=0;

        while (($data = fgetcsv($handle, 0, ',')) !== FALSE) {  
            if ($row_count==0) { 
                $row_count++;
                } else {
                    $row_count++;
                    $works_id = sanitiseData($data[0]);
                    $title = sanitiseData($data[1]);
                    $first_name = sanitiseData($data[2]);

                    //Use data to insert into db  
                    $sql = mysql_query("INSERT INTO csv_employee_personal (id,works_id,title,first_name) VALUES ('','$works_id','$title','$first_name')");
                }
        }  

        //delete csv file  
        unlink($file_path);  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:15:56+00:00Added an answer on June 8, 2026 at 8:15 am

    I’m presuming this is what your data looks like
    “data”,”data2″,”data3,and some more”,”data4″

    my regex is very bad , but I would think it would be your best solution.

    in the mean time you can recursively go trough each character on a line and keep track of commas and field delimiters and when you realize that you are looking at a comma that was not followed by a closing ” then you can escape it.

    If the example data I gave u matches your data, give me a few mins while I write a function for you to escape commas

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add in the ability for users of my app to
So I'm trying to add some ability to my project to allow user-defined properties
Using MS Visual C++ and Boost asio, I'm trying to add the ability to
I have a WinForms app and am trying to add the ability to start
Trying to add the ability to delete a Folder using FTP and all subfolders
I'm trying add data triggers to the default combobox style so each text item
Trying to add a blank sample app for a rails tutorial to GitHub, but
Trying to add email notification to my app in the cleanest way possible. When
Trying to add a class object into a List using reflection, but when invoking
I am using NHibernate in a project, and I am trying to add it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.