Import users into diffrent lists from csv

Hi there,
I have a problem at the moment to migrate from one Newsletter Script to phplist: I have arround 40 diffrent categories a user can subscripe to. Now I exportet them to a list as CVS within the format:
Email;Is this subscriber confirmed;Is this subscriber blacklisted;name;list;
valid@mail.com;1;1;Mr. User Name;general development;
second@mail.com;1;1;Mrs. Another Name;updates;
The List “general development”/“updates” exists within phplist. I can slip the large list into 40 small lists and import to the right list without a problem, but I’m looking for a way to extract the list from csv. The right query I allready have:

 Sql_Query("insert into {$tables["listuser"]} (userid,listid,entered,modified) values($id,$listID,now(),now())");

I’m just missing the correct lines where values from $values = explode($_SESSION["import_field_delimiter"], $line); can be modified to pass to insert query. I’m guessing it’s arround line 383 in import2.php here an attribute gets insert into “user_attribute” but define an attribute list and then check and insert seems strange…

		  if($attribute_index == /*index_of_list*/){
			  Sql_Query("insert into {$tables["listuser"]} (userid,listid,entered,modified) values($userid,/*id_of_mylist*/,now(),now())");
		  }

Hope someone has a better solution for me.

Thx Moritz

Hi Moritz,
It has been my experience that breaking these complex commands into a series of smaller commands makes it easier to deal with.

I’d suggest an approach where you take your data that you want to import, and insert into a new table. Then populate each record with the additional data, and then use a insert or update command , using the data in each record, to perform your desired task.