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

  • SEARCH
  • Home
  • 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 9057683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:31:22+00:00 2026-06-16T14:31:22+00:00

I have simple csv file which is tab delimited which i have to use

  • 0

I have simple csv file which is tab delimited which i have to use as it is because it is coming from somewhere and i hvae to read it and insert it into my db i have used a simple php code to read it

if(($handle = fopen("var/import/MMT29DEC.csv","r"))!==FALSE){
            /*Skip the first row*/
            fgetcsv($handle, 1000,chr(9));
            while(($data = fgetcsv($handle,1000,chr(9)))!==FALSE){
                    print_r($data[0]);
                        }
}

When print_r the data it shows like

Array ( [0] => 01SATAPC [1] => 40ATAPC [2] => [3] => 21P [4] => SERIAL ATA POWER CABLE [5] => 0.00 [6] => 2.00 [7] => 0 [8] => Power Supplies [9] => SERIAL ATA POWER CABLE [10] =>
4 TO 15 PIN 160MM
[11] => [12] => [13] => [14] => MELBHO [15] => 0.000 [16] => [17] => Order to Order [18] => 4 [19] => 2013-01-18 ) 

Which is the desired result but when i go to access the particular column value using the $data[‘index’] e.g. $data[8] or $data[1] it weirdly giving me garbage values says for some iterations it give me right values but after 10-15 rows its starting giving me the some numbers and other column values….. i don’t know whats is going on with this as far as i know it should be formatting issue i have tried open the file in excel and its coming fine….

  • 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-16T14:31:24+00:00Added an answer on June 16, 2026 at 2:31 pm

    @ravisoni are you sure that the second parameter to fgetcsv of 1000 is longer than the longest line in your file? Try setting it to 0 as the docs say [php.net/fgetcsv] and see if that makes a difference.

    if(($handle = fopen("var/import/MMT29DEC.csv","r"))!==FALSE){
                /*Skip the first row*/
                fgetcsv($handle, 0,chr(9));
                while(($data = fgetcsv($handle,0,chr(9)))!==FALSE){
                        print_r($data[0]);
                            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB web application that reads from a CSV file which contains
I have created a simple form which is loading a csv file with few
I have a simple rake task importing records from a CSV file and saving
I have a simple java code that reads text csv file that contains sentences
I have another csv file where I am trying to do a simple word
I have a CSV file which contains numbers,date and text. I have to extract
I have a CSV file that is being exported from another system whereby the
I'm looking at my delimited-file (e.g. CSV, tab seperated, etc.) parsing options based on
I have a simple csv file containing 2 columns of numbers with the headers
I have idsfile.csv which is a comma separated file of ids (with no new

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.