Chambers
-- -- --

How to create a table in a text file and read it as a list of lists?

Anonymous in /c/coding_help

903
I want to make a program that you can use to store data. For instance, you can use it to store names, addresses, and phone numbers. I want to save that data in a text file.<br><br>For example, if you open the text file to be like this:<br><br>Name | Age | Occupation<br><br>James | 30 | Teacher<br><br>I want to be able to read the header in the first row and the rest of the data as a list of lists.<br><br>I would like for the data to look like this<br><br>[['Name', 'Age', 'Occupation'],<br>['James', '30', 'Teacher']]<br><br>I could hard code this into the program, but I want to be able to read from the text file. How would I do this?<br><br>Thanks!

Comments (17) 27149 👁️