Informatics2-2021/Lab10

A MathWikiből

Home

Tartalomjegyzék

Exercise

write_csv

Write the first.csv and second.csv files based on what you learned in the lecture.

In the first.csv:

enter your first and last names separated by a comma in the first line. 
In the second line, separate the title of your favorite movie with a comma, when it was made and the name of the actor and the director from the movie.

In the second.csv:

Enter your last names and first names with a tab in the first line.
In the second line, write which area of mathematics interests you the most.
And the third line is what you would like to work on in the future (several things can be listed).

read_csv

Write a function that reads a .csv file.
The function should have an optional delimiter parameter with a default value of ','.
Write that the function works even if the values in the file are not separated by ',' but by tabs. (In this case, the input delimiter = '\ t' also indicates this, it does not need to be detected automatically.)
The function returns a list of lists in which the lists correspond to the rows and the elements are the words in the row separated accordingly.

write_json

Write a json file that contains your name and one of of your friends and your favorite movies( several movies can be listed) .
Its name should be sample.json, it should have two keys: "first" contains your information and "second" contains your friend informations .

For example, for me:

{'first': {'Name': 'Muhammad Imran', 'favorite movie': 'Among the stars'}, 'second': {'Name': 'Zong', 'favorite movie': ['It' , 'Iron man']}}

read_json

Write a function whose input is a .json file that has the same format as the one we wrote. The output is the favorite movie of the person in the .json file.

Személyes eszközök