File converter to different extensions
Project description
Goal
This is a package which converts files to different types.
Supported extensions
- CSV
- ARFF
Installation
pip install filepy --upgrade
Usage
This library is mainly divided into 2 ideas, namely writers and readers. Readers will read your files, writer will write in appropriate format.
Available classes:
- CsvReader
- CsvWriter
- ArffReader
- ArffWriter
Suppose that you have a csv file: example1.csv
.
You want to convert this file to an arff format for instance converted.arff
from filepy.csv_reader import CsvReader
from filepy.arff_writer import ArffWriter
from filepy.file_converter import convert
csv_reader = CsvReader('example1.csv', delimiter=';')
arff_writer = ArffWriter('converted.arff', delimiter=',')
convert(input_reader=csv_reader, output_writer=arff_writer)
Additional options
Each writer and reader has additional options to use.
CsvReader
CsvReader(path_to_file, delimiter = ',', first_line_column_names = True, skip_first_column = False)
delimiter - how data is separated, can be regex
first_line_column_names - uses first line to read columns
skip_first_column - skips first column of data
After creating object you can get data from it.
csv_reader = CsvReader('your/path/to/file')
data = csv_reader.dto.data
column_names = csv_reader.dto.data
CsvWriter
CsvWriter(path_to_file, delimiter = ',', skip_writing_columns = False)
delimiter - how data will be separated in generated file
skip_writing_column - whether first line in generated file should have columns names
ArffReader
ArffReader(path_to_file, delimiter = ',')
delimiter - how data is separated, can be regex
After creating object you can get data from it.
csv_reader = CsvReader('your/path/to/file')
data = csv_reader.dto.data
column_names = csv_reader.dto.columns
ArffWriter
ArffWriter(path_to_file, delimiter= ',')
delimiter - how data will be separated in generated file
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file filepy-0.17-py3-none-any.whl
.
File metadata
- Download URL: filepy-0.17-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951d998bbd7324393c3d00700091ca34da49742971f111e27cd25554f8bfd9e5 |
|
MD5 | 5937f71e9129fa643472a279c5d9d6cd |
|
BLAKE2b-256 | cf870e2f59cd0d896701b4ccd5198dc98792a2e200c1074012466ce7fc8a8cbb |