[PYTHON] Package filer for simple file operations

Introduction of package filer for simple file operations

Introduction

When reading a csv file with python

import csv

with open('name.csv', 'r') as f:
    reader = csv.reader(f)
    for row in reader:
        print row

It is necessary to do this, but it is troublesome to do this every time ... You can save it as a function, but if you package it, it will be easy to introduce! !! So I registered with pip.

Introduction

If it is 2 system

pip install filer2

If it is 3 system

pip install filer3

Please. (The contents are slightly different between filer2 and filer3, but the same thing can be done)

How to use

Functions that can be used with filer

9 types. For example, reading a csv file and writing

from filer2 import Filer

#Read csv file
data = Filer.read_csv('inputpath')
#Writing csv file
Filer.write_csv(data, 'outputpath')

Can be done with.

Similarly, you can operate tsv files, txt files, and pkl files.

conv_encoding is a function that outputs the encoding of characters

from filer2 import Filer

print Filer.conv_encoding(string)

Use as.

At the end

This is convenient when you want to perform a small file operation. Well, I should use read_csv of pandas in the first place ...

Digression

I registered pypi after a long time, but Apparently now

python setup.py register

Then Server response (410): This API is no longer supported, instead simply upload the file. I got the error. Apparently, the regsiter in setup.py is deprecated. Now I'm using a package called twine

twine register dist/*
twine upload dist/*

Seems to be good. Click here for details http://qiita.com/tokyo-noctambulist/items/cafcbd589e39d45d693f http://elicon.blog57.fc2.com/blog-entry-422.html

Recommended Posts

Package filer for simple file operations
Basic commands for file operations
File operations
File operations in Python
[Python] File / directory operations
Pathlib provides a common interface for file path operations
File operations with open — "../"
File operations in Python
Summary of python file operations
Simple HTTP Server for python