Soil quality across the world is degrading, and this will result in 40% less food for everyone by 2045. Check out the Save Soil movement, and find out what you can do to contribute to a better world for our children.
Note: This is not an ad. We are not being paid to put up this notice.
In a previous article, we explored how to import a CSV file into a table in MySQL. This is a continuation of that article, where we will explore how to split CSV files that contain data which is supposed to go into multiple tables.
Essentially, the CSV file format is meant to represent tabular data. The above CSV file represents the following table:
Username
Email
Address
Contact
johndoe
john@example.com
71 Pickering Street, Singapore, Singapore
+65-91234567
janedoe
jane@website.com
24 Raffles Lane, Singapore, Singapore
+65-81234567
marysmith
mary@smith.com
83 Riveting Road, Singapore, Singapore
+65-97654321
bobsmith
bob@smith.com
84 Riveting Road, Singapore, Singapore
+65-87654321
Due to their tabular nature, data in a CSV file can very easily be imported into and stored in an SQL table. The commands to do that, however, are not very well-documented online.
If a CSV file does not open as a text file on your computer, that’s because your computer is opening the file with a spreadsheet program such as Microsoft Excel. In such a case, to see the file as text, you will want to open these files on a text editing software such as Notepad.