Import CSV File

Small, short code snippets that other people may find useful. Do you have a good regex that you would like to share? Share it! Even better, the code can be commented on, and improved.

Moderator: General Moderators

Post Reply
construct
Forum Newbie
Posts: 5
Joined: Sat Jul 02, 2011 12:58 pm

Import CSV File

Post by construct »

I added some code to import a csv file.

I'm sharing it here as well as mycsv import function:

Code: Select all


function importCSV {
$handle = fopen("file.csv", 'r');
while(($data = fgetcsv($handle, 1000, ",")) !== false)
{
    list($col1, $col2, ...) = $data;
}
fclose($handle);
}

User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Import CSV File

Post by McInfo »

There are two syntax errors:
  • invalid function definition (no parameter list)
  • invalid list() syntax (pseudo-code?)
The function has no inputs, no output, and no useful side-effects; so what is the purpose?
Esteban11
Forum Newbie
Posts: 3
Joined: Thu Nov 10, 2011 4:46 am

Re: Import CSV File

Post by Esteban11 »

I've been searching for a while now but can't seem to find answers so here goes...

I've got a CSV file that I want to import into a table in Oracle (9i/10i).

Later on I plan to use this table as a lookup for another use.

This is actually a workaround I'm working on since the fact that querying using the IN clause with more that 1000 values is not possible.

How is this done using SQLPLUS?
Post Reply