Jump to content

CSV Import


binarylime

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/226696-csv-import/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.