I am using drupal 7 and have the data module managing/adopting a table I have manually added to my drupal db. What I was hoping was that when a csv file is uploaded via a specific content type I could use rules to execute some custom php and import the csv into the table (as feedsdataprocessor no longer exists from what I can see). I see there is a drupal_write_record function but the problem is first how do I get the array out of the file and secondly my file can be different to the table in structure - for example, sometimes the csv will have columns 1,2,3,4 and sometimes 3,4,5,6,7. How can I check the headers and import into the managed table?
feedback
|
|
So conceptual steps:
I'm not sure how the rules integration will work I'm assuming you can pass the node into it some how. So for step one assuming it's stored into $node and your field is named field_csv_file we can hand the URL to fopen():
So now we can open fopen() to get a file handle:
If there's no value we don't want to procede. Read the header row:
Then load each row and convert the format:
Close the file:
So issues with this:
| |||
feedback
|