[Python] Convert Shift_JIS to UTF-8

environment

Python 3.7.5

Source code

Conversion.py


import codecs
import sys

args = sys.argv

def main():
    shiftjis_path = args[1]
    utf8_path = args[2]

    #Character code utf-Convert to 8 and save
    fin = codecs.open(shiftjis_path, "r", "shift_jis")
    fout_utf = codecs.open(utf8_path, "w", "utf-8")
    for row in fin:
        fout_utf.write(row)
    fin.close()
    fout_utf.close()

if __name__ == '__main__':
    main()

I read the Shift_JIS file, create a new file with UTF-8, and write it.

How to use

Specify both the conversion source file Path and the output destination file Path as relative paths!

$ python Conversion.py <Path of conversion source file> <Path of output file>

Summary

It took about several minutes to convert the character code, so I created it to save time. I intended to post every day, but it's been a while since my last post. .. .. I'm going to start shaved again for 3 days from today! !! !!

Recommended Posts

[Python] Convert Shift_JIS to UTF-8
[python] Convert date to string
Convert numpy int64 to python int
[Python] Convert list to Pandas [Pandas]
Convert Scratch project to Python
Convert python 3.x code to python 2.x
Convert markdown to PDF in Python
Change python default encoding to utf-8
Workflow to convert formula (image) to python
Convert list to DataFrame with python
Python> list> Convert double list to single list
[Python] Convert natural numbers to ordinal numbers
Convert decimal numbers to n-ary numbers [python]
Python> tuple> Convert double tuple to single tuple
[Python] How to convert db file to csv
Updated to Python 2.7.9
Convert to HSV
Convert Python> two value sequence to dictionary
[Python] How to convert a 2D list to a 1D list
How to convert Python to an exe file
[Python] Convert csv file delimiters to tab delimiters
Convert psd file to png in Python
To set default encoding to utf-8 in python
Convert Excel data to JSON with python
Convert Hiragana to Romaji with Python (Beta)
Convert from katakana to vowel kana [python]
Convert FX 1-minute data to 5-minute data with Python
python> Convert tuple to list> aList = list (pi_tuple)
[Python3] Switch between Shift_JIS, UTF-8 and ASCII
Convert Python date types to RFC822 format
Convert HEIC files to PNG files with Python
Convert Chinese numerals to Arabic numerals with Python
Convert from Markdown to HTML in Python
Convert absolute URLs to relative URLs in Python
"Backport" to python 2
Sample to convert image to Wavelet with Python
Python code to convert region mesh code to latitude / longitude
Convert FBX files to ASCII <-> BINARY in Python
Convert PDF to image (JPEG / PNG) with Python
Convert "number" of excel date to python datetime
Convert PDFs to images in bulk with Python
Python script to convert latitude / longitude to mesh code
Convert svg file to png / ico with Python
Convert Windows epoch values to date with python
How to convert SVG to PDF and PNG [Python]
Convert STL to Voxel mesh using Python VTK
Convert exponential notation float to str in Python
Convert cubic mesh code to WKT in Python
Convert strings to character-by-character list format with python
How to install Python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Decode ShiftJIS to Unicode
Rewrite Python2 code to Python3 (2to3)
Convert jupyter to py
How to install python
Introduction to Python language
Convert keras-yolo3 to onnx
Introduction to OpenCV (python)-(2)
Convert dict to array
Note to daemonize python