Some more examples
Some examples
Merge two files
Student Marks manager
CSV to SQL generator
Merge two files
Let's say you have two files, "file.txt" and "file2.txt" and you want to merge them. One can try sorting the file and then copy pasting and running some duplicate removal program, or one can use Python.
First read both the files and create a dictionary. In that dictionary, we create an integer entry about each line, if it is not present in the dictionary keys, we add a value, otherwise we increment the value, that way, we can find out the duplicate values if needed.
file name: ch13/merge.py
Student Marks Manager
Say that you want to build some analytics software for a school for some reason, you have the following data in a csv file:
file name: ch13/student_scores.py
CSV to SQL generator
Let's say that you have a csv file which you want to import into a database and for some reason your db client doesn't support direct import, so you have the task to convert the data in csv file into insert statements.
This is a crude way to convert data, if you are having access to the database client in python, you can write your own importer without having to generate SQL statements.
file name: ch13/csv_to_db.py
Links
Last updated