Web Analytics Made Easy -
StatCounter searching a csv file and outputting - CodingForum

Announcement

Collapse
No announcement yet.

searching a csv file and outputting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • searching a csv file and outputting

    Hi,
    I did a couple searches on the forum and could not find the answer so I thought I would post my question.

    I am trying to search this file on our server http://www.jscspeed.com/cgi-bin/inventory/inv.CSV

    we need our search to look like this http://www.motovicity.com/stock/

    just product search with a button, then I want the input (part number) to be searched for in the above listed csv file and I would like to output column B and E?

  • #2
    There are several different approaches that can be taken to parse/search a csv file, but before working with any code, let's take a look at your csv file. There is 1 issue with your file which will make the parsing/searching more difficult. You're using the comma as your seperator and you have commas embedded in 1 or more of your data fields. How was the csv file created? I assume it was exported from a spreadsheet. Do you have the option to export it using a different field seperator?

    Comment


    • #3
      the CSV file appears to be properly formatted:

      "aem22-435B","2003+ Evo 8, AEM Shortram Intake, Blue",0

      text::csv or text::csv:simple should both work OK.

      the very first (or first and second) line of the file looks messed up though:

      Code:
      ,"Item Description","On Hand"
      "Inventory",,
      should be:

      Code:
      "Item","Description","On Hand"
      some code:

      Code:
      while(<DATA>) {
         chomp;
         s/^"//;
         my ($item,$desc,$qty) = split(/","|",/); 
         #search code here
         print "$item\t$desc\t$qty<br>\n";
      }

      Comment

      Working...
      X