Categories: Uncategorised

Handling CSV in Python

In Python, handling CSV (Comma Separated Values) files is easy using the built-in csv module.

Here’s an example of how we can write/read a CSV file:

import csv;

def csvHandling():
    N=[25,17,19,13,12,15]
    file = open("1.csv","w", newline='');
    csv_writer=csv.writer(file)
    csv_writer.writerow(N)    
    file.close()
    file = open("1.csv","r", newline='');
    csv_reader=csv.reader(file)
    for row in csv_reader:
        print("printing rows in csv")
        print(row)  
    file.close()

csvHandling();

Here we are writing the contents of a list to csv and displaying the contents by reading the csv.

mahendravarman.m@gmail.com

Recent Posts

Spring Webflux Functional Endpoint – File Upload

In this blog using the Spring WebFlux module, we are going to leverage the functional…

9 months ago

Serverless Functions with Spring Cloud Function, AWS Lambda

Spring Cloud Function is a project within the Spring ecosystem that allows developers to build…

9 months ago

Spring Boot + RabbitMQ – Decoupling Microservices Communication

RabbitMQ is an open-source message broker software that implements the Advanced Message Queuing Protocol (AMQP).…

9 months ago

Spring Integration – Sending files over SFTP

Spring Integration is a powerful extension of the Spring Framework designed to support the implementation…

9 months ago

Spring Cloud Config Client

The Spring Cloud Config Client is a component of the Spring Cloud framework that enables…

10 months ago

Spring Cloud Config Server – JDBC Backend

Spring Cloud Config Server provides a centralized location for managing and serving configuration information to…

10 months ago