Answers for "python deal with csv"

16

python csv reader

with open(r'c:dlFrameRecentSessions.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            print(f'Column names are {", ".join(row)}')
            line_count += 1
        else:
            print(f't{row[0]} works in the {row[1]} department, and was born in {row[2]}.')
            line_count += 1
    print(f'Processed {line_count} lines.')
Posted by: Guest on January-13-2020
0

python write csv line by line

##text=List of strings to be written to file
with open('csvfile.csv','wb') as file:
    for line in text:
        file.write(line)
        file.write('n')
Posted by: Guest on October-30-2020

Code answers related to "python deal with csv"

Python Answers by Framework

Browse Popular Code Answers by Language