Read csv file python - stack overflow
Here are some minimal complete examples how to read CSV files and how to write CSV files with Python. Show Python 3: Reading a CSV filePure Python
After that, the contents of
Please note that CSV reads only strings. You need to convert to the column types manually. A Python 2+3 version was here before (link), but Python 2 support is dropped. Removing the Python 2 stuff massively simplified this answer. Related
mpuHave a look at my utility package
Pandas
See If you haven't heard of Seaborn, I recommend having a look at it. OtherReading CSV files is supported by a bunch of other libraries, for example:
Created CSV file
Common file endings
Working with the dataAfter reading the CSV file to a list of tuples / dicts or a Pandas dataframe, it is simply working with this kind of data. Nothing CSV specific. Alternatives
For your application, the following might be important:
See also: Comparison of data serialization formats In case you are rather looking for a way to make configuration files, you might want to read my short article Configuration files in Python I am doing coursework where it requires me to make a Quiz programme where an account for a user is created and stored to a CSV along with personal information. It then requires me to read from a CSV file and read the questions and answers for the module to run and then it stores the test data to the CSV where all the account information is stored. I have successfully written to the CSV however I am having a problem with reading correctly. The CSV is set up with 2 columns and 5 rows in A1, A2, A3, A4 and A5 is where the questions are stored and in B1, B2, B3, B4 and B5 is where the answers are stored for the question on the row. Currently I am attempting to print the Question into an input and then use an if statement to check it against the answer I have stored in the CSV. Currently I am having problems with printing everything within the cell and I am having to use ranges. A section of my python code is as follows...
How do I print the whole cell into the input without having to do the ranges in the row? |