Output to csv file with Python

I want to output in CSV format

For example, when you want to output the scraped information in csv format and go to Excel.

csv.py


# -*- coding: utf-8 -*-

import csv

#File open
f = open('output.csv', 'w')
writer = csv.writer(f, lineterminator='\n')

#Keep data in list
csvlist = []
csvlist.append("hoge")
csvlist.append("fuga")

#output
writer.writerow(csvlist)

#File close
f.close()

By the way, if the second argument of file open is ʻa`, it will be in append mode.

Recommended Posts

Output to csv file with Python
[Python] Write to csv file with Python
Write to csv with Python
Download csv file with python
How to read a CSV file with Python 2/3
I tried to touch the CSV file with Python
Output cell to file with Colaboratory
How to convert JSON file to CSV file with Python Pandas
[Python-pptx] Output PowerPoint font information to csv with python
Read CSV file with python (Download & parse CSV file)
Output color characters to pretty with python
[Python] Convert csv file delimiters to tab delimiters
Output Python log to console with GAE
[Part1] Scraping with Python → Organize to csv!
Python> Output numbers from 1 to 100, 501 to 600> For csv
Csv tinkering with python
Read Python csv file
[Python] Convert CSV file uploaded to S3 to JSON file with AWS Lambda
Scraping tabelog with python and outputting to CSV
Read JSON with Python and output as CSV
[Python] How to read excel file with pandas
Convert svg file to png / ico with Python
Writing logs to CSV file (Python, C language)
I tried to output LLVM IR with Python
Output python log to both console and file
Write CSV data to AWS-S3 with AWS-Lambda + Python
I want to write to a file with Python
2017-02-19 Python> Link> Redirect to output file immediately> sys.stdout.flush ()
Speed evaluation of CSV file output in Python
Read CSV file with Python and convert it to DataFrame as it is
Error due to UnicodeDecodeError when reading CSV file with Python [For beginners]
Connect to BigQuery with Python
Read csv with python pandas
Draw netCDF file with python
Post to slack with Python 3
Output to syslog with Loguru
Switch python to 2.7 with alternatives
Procedure to load MNIST with python and output to png
How to measure mp3 file playback time with python
How to output CSV of multi-line header with pandas
[Python] A memo to write CSV vertically with Pandas
Read json file with Python, format it, and output json
Python script to create a JSON file from a CSV file
Extract the xz file with python
Python: How to use async with
Link to get started with python
Make apache log csv with python
Tips on Python file input / output
[Automation with python! ] Part 1: Setting file
Implemented file download with Python + Bottle
Create folders from '01' to '12' with python
Nice to meet you with python
[Python] Read the csv file and display the figure with matplotlib
Input / output with Python (Python learning memo ⑤)
Write standard output to a file
Create an Excel file with Python3
Convert list to DataFrame with python
MP3 to WAV conversion with Python
To do tail recursion with Python2
How to get started with Python
[Note] Hello world output with python