restructure, bump version

This commit is contained in:
iuvbio 2019-01-28 23:27:28 +01:00
parent bdb5ab92e8
commit a140a5d4b9
4 changed files with 36 additions and 31 deletions

View File

@ -1 +1 @@
from .read_ods import read_ods
from .parser import read_ods

View File

@ -2,14 +2,7 @@
import ezodf
import pandas as pd
def ods_info(doc):
print("Spreadsheet contains %d sheet(s)." % len(doc.sheets))
for sheet in doc.sheets:
print("-"*40)
print(" Sheet name : '%s'" % sheet.name)
print("Size of Sheet : (rows=%d, cols=%d)" % (
sheet.nrows(), sheet.ncols()))
from .tools import sanitize_df
def load_ods(doc, sheet, headers=True, columns=None):
@ -52,25 +45,6 @@ def load_ods(doc, sheet, headers=True, columns=None):
return df
def sanitize_df(df):
# Delete empty rows
rows = len(df) - 1
for i in range(rows):
row = df.iloc[-1]
if row.isnull().all():
df = df.iloc[:-2]
else:
break
# Delete empty columns
cols = []
for column in df:
if not df[column].isnull().all():
cols.append(column)
df = df[cols]
len(df.columns)
return df
def read_ods(file_or_path, sheet, headers=True, columns=None):
"""
This function reads in the provided ods file and converts it to a

View File

@ -0,0 +1,31 @@
"""Provides utility functions for the parser"""
def ods_info(doc):
"""Prints the number of sheets, their names, and number of rows and columns"""
print("Spreadsheet contains %d sheet(s)." % len(doc.sheets))
for sheet in doc.sheets:
print("-"*40)
print(" Sheet name : '%s'" % sheet.name)
print("Size of Sheet : (rows=%d, cols=%d)" % (
sheet.nrows(), sheet.ncols()))
def sanitize_df(df):
"""Drops empty rows and columns from the DataFrame and returns it"""
# Delete empty rows
rows = len(df) - 1
for i in range(rows):
row = df.iloc[-1]
if row.isnull().all():
df = df.iloc[:-2]
else:
break
# Delete empty columns
cols = []
for column in df:
if not df[column].isnull().all():
cols.append(column)
df = df[cols]
len(df.columns)
return df

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages
VERSION = "0.0.2"
VERSION = "0.0.3"
setup(name="pandas_ods_reader",
version=VERSION,
@ -9,7 +9,7 @@ setup(name="pandas_ods_reader",
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities',
],
keywords='data io pandas ods',
@ -19,5 +19,5 @@ setup(name="pandas_ods_reader",
license="MIT",
packages=find_packages(),
zip_safe=False,
install_requires=["ezodf", "pandas"]
install_requires=["ezodf", "pandas", "lxml"]
)