Parse CSV file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naveensundar
    New Member
    • Apr 2007
    • 1

    Parse CSV file

    I have a number of Tab-delimted files that I need to upload into mySQL server. The first two rows of the file is garbage and the next five rows is what I need to upload for each of these files. Each row has five columns. Additionally, I need to insert the file name also as a row.

    I am envisioning a button to select and upload the data from each file into my database. Could anyone help me providing the code to build the program. Any help is appreciated.


    Thanks in advance

    -Naveen
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    If this was in fact a CSV (that is Comma Separated Values) file, you could use the built in CSV functions that come with PHP.
    If these are Tab Delimited, I would say the best route to go would be to read each line from the file and explode on the \t character.
    You can get the uploaded file name from the $_FILES variable.

    Originally posted by naveensundar
    I have a number of Tab-delimted files that I need to upload into mySQL server. The first two rows of the file is garbage and the next five rows is what I need to upload for each of these files. Each row has five columns. Additionally, I need to insert the file name also as a row.

    I am envisioning a button to select and upload the data from each file into my database. Could anyone help me providing the code to build the program. Any help is appreciated.


    Thanks in advance

    -Naveen

    Comment

    Working...