Read the csv lines and save them in a separate text file, named as a line - python


i have some problem with simple code. I have a csv file with one column, and hundreds rows. I would like to get a code to read each line of csv and save it as separate txt files. What is important, the txt files should have be named as read line.

Example: 1.Adam 2. Doroty 3. Pablo

will give me adam.txt, doroty.txt and pablo txt. files. Please, help.

This should do what you need on python 3.6

with open('file.csv') as f:       # Open file with hundreds of rows
    for name in'\n'):  # Get list of all names
        with open(f'{name.strip()}.txt', 'w') as s:  # Create file per name