“Como converter a lista em CSV em Python” Respostas de código

Como converter a lista em CSV em Python

import pandas as pd    

list1 = [1,2,3,4,5]
df = pd.DataFrame(list1)
df.to_csv('filename.csv', index=False)

#index =false removes unnecessary indexing/numbering in the csv
Sore Seal

Lista para CSV

import csv

with open("out.csv", "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerows(a)
Splendid Sloth

Como converter CSV em lista

open('file.csv', 'r').read().splitlines() #assuming you want each row to be an individual element in the list
TheRubberDucky

Respostas semelhantes a “Como converter a lista em CSV em Python”

Perguntas semelhantes a “Como converter a lista em CSV em Python”

Procure respostas de código populares por idioma

Procurar outros idiomas de código