binarylime Posted February 4, 2011 Share Posted February 4, 2011 I'm trying to import some data from a CSV into a MySQL database and need a little help! Thanks in advance... My database has 'user' and 'class' fields. In my CSV, each user id is associated with many classes. In the CSV data below for example, users 123221 is a member of classes 8G/F2, 8G/H1, 8G/M1 and so on. User 223214 is a member of classes 7A/M1, 7A/Ad and so on. UID,Class 123221,8G/F2 ,8G/H1 ,8G/M1 ,8G/S1 ,8G/It1 ,8G/Te1 ,8Z/M1 ,8W/Pe3 ,8W/Ad ,8W/Dm ,8W/En ,8W/Gg ,8W/Mu ,8W/Rs ,CLS 8W 223214,7A/M1 ,7A/Ad ,7A/Dm ,7A/En ,7A/F ,7A/Gg ,7A/H ,7A/Mu ,7A/Rs ,7A/S ,7A/It1 ,7A/Te1 ,7W/Pe4 ,CLS 7A The user id appears next to the first class, but is missing for every class after that (but the subsequent classes should still be linked to that user). How do I import this CSV so that each class is assigned to the relevant user id? I presume I'll need to use some PHP magic to read the CSV into some arrays but I'm not sure where to start! Thanks for your help. Andy Quote Link to comment Share on other sites More sharing options...
binarylime Posted February 8, 2011 Author Share Posted February 8, 2011 OK, I've been reading up and I think I need to parse the CSV into a multi dimensional array. The problem is still with the missing user id's though. Any one got any thoughts? Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted February 13, 2011 Share Posted February 13, 2011 Sorry, what's the question? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.