Filter a .csv file using PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OrangePanda
    New Member
    • Jun 2014
    • 1

    Filter a .csv file using PHP

    I've got a feed coming in from an external source in a csv file. This feed contains a lot of information that is redundant. I'm looking for a way to open that csv file, filter it by a certain criteria then save the file again?

    To better explain.

    The feed contains product information on a wide range of computer/audio visual equipment.

    If I wanted to open this and only keep the lines that had Projector in the category column how would I go about this?

    Thanks for any help in advance

    If it helps this is the csv file I am trying to edit



    I'm trying to filter by category values
    Last edited by OrangePanda; Jun 11 '14, 09:50 AM. Reason: Additional Information
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    1) produce code to read the complete data in some fields
    2) add an IF statement to check if 'category' contains 'Projector'
    3) only if previous step checks, store the info, ELSE ignore...

    Comment

    • Jennypliskin
      New Member
      • Sep 2013
      • 30

      #3
      CSV Quick Filter v0.39r
      Download:
      http://www.autohotke...ilter/csvqf.zip
      (consists of one AHK file + modified CSV lib (with bug fixes) + Attach lib by majkinetor)

      This script allows you to load a CSV file (any delimited file)
      and use various search criteria to filter the listview.
      You can export the results to a new file.

      Note: an entire row of the CSV is searched at once and not
      on a cell by cell basis to provide faster search results.
      For large files it will be fairly slow, it will also depend on your PC specs how fast it will display all the results.

      Updated (0.38i) Command line options:

      Command line options:
      CSVQF file ["delimiter"] ["header"] ["Columns to use in CSV"]
      Example, opening a | delimited file:
      CSVQF data.csv "|"

      Use the first row as header for listview: (header = 1,Y,Yes,T,True)
      CSVQF data.csv "," "1"

      Use \t for a tab delimited file
      CSVQF tabdata.txt "\t"

      Only use specific columns (1 & 5):
      CSVQF data.csv "," "0" "1,5"

      or run CSVQF.ahk, select a file and select your preferences.

      Comment

      Working...