Results 1 to 6 of 6
  1. #1

    Member Since
    Dec 16, 2006
    Unhappy Read data from csv file using php
    Hi guys,

    What I'm trying to achieve here is a web page that will query a csv file and display data from that file. From what I've seen the way forward is using PHP.

    After having trawled through Google I'm still unsure, I'm a newbie when it comes to php.

    Basically I want to enter the first entry of a row from the csv file (which will be a 3 letter code) into a text box, click a 'submit' button (or press <enter> ) and then I want the web page to display the data from that row in a table or something.

    Any help would be appreciated

  2. #2

    xstep's Avatar
    Member Since
    Jun 25, 2005
    On the road
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    This can be done in any scripting or programing language. You need some programming skills to accomplish this. If you don't have any, then it is time to learn.

    You would have page with the box to enter the value, pass that back to the server which would read one row at a time from your csv file, convert it, at least up the the first 'column' to plain text, and compare that to the entered value. If the value matches, convert the remaining line and pass the new table back, otherwise repeat with the next row. If multiple rows can have repeating key values, then you have to read the entire file and build up your table.

    You might find a library that can read in a CVS file and convert the columns to variables to make it easier to deal with. Often the scripting language maintainers have a page for libraries you can search through.
    CameraTime - Time lapse photography for novice and advanced users.

    When asking questions, post the version of your software. You'll receive better answers.

    Please post your results to the thread as it is good feedback.

  3. #3

    Murlyn's Avatar
    Member Since
    Jun 11, 2003
    Mount Vernon, WA
    MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
    A couple php functions that you might want to look into:

    PHP: fgetcsv - Manual
    PHP: print_r - Manual

    Also your post variables will be found in the $_POST array

  4. #4

    Member Since
    Dec 16, 2006
    I think I'm going to have to learn php fast as I have no idea how to string it all together.

    Can anyone help further?

  5. #5

    Member Since
    Jun 26, 2011
    Reading CSV data using PHP is fairly easy. You can use fgetcsv to do this.
    Here is one example to read CSV file using PHP.

    Hope this helps!

  6. #6

    [DT]'s Avatar
    Member Since
    Dec 23, 2010
    Vilano Beach, FL
    MBP 15" 16/500/2.3GHz, iPad 4 32GB, iPhone 5 32GB
    If this CSV doesn't change much (or even if it does for that matter), you might think about moving it into a structured database.

    Then running various queries/filters/sorts would be easier and faster, and you can use existing functions for easily handling your data.

    So you could either import it manually (in the case where it doesn't change [often]), or use a browse/upload control to select a local file, move it to the server, parse it, drop it into a DB.

    In terms of "how", that's probably a larger post than this MB supports

    Have fun!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export MAC contacts in CSV file format??
    By greendragonflyz in forum Switcher Hangout
    Replies: 1
    Last Post: 09-27-2012, 02:13 PM
  2. Using Pages Mail Merge from CSV file
    By staroftheshow in forum macOS - Apps and Games
    Replies: 5
    Last Post: 04-25-2011, 06:23 PM
  3. Importing hotmail CSV file to Adress Book
    By misterpouliot in forum macOS - Apps and Games
    Replies: 0
    Last Post: 12-21-2010, 01:44 PM
  4. Please help with CSV file import?
    By davidbanks in forum macOS - Operating System
    Replies: 3
    Last Post: 05-01-2010, 06:46 AM
  5. Importing CSV File into Address Problems!
    By oleviking in forum Switcher Hangout
    Replies: 6
    Last Post: 06-08-2008, 06:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts