restructure, bump version
This commit is contained in:
parent
bdb5ab92e8
commit
a140a5d4b9
|
|
@ -1 +1 @@
|
||||||
from .read_ods import read_ods
|
from .parser import read_ods
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,7 @@
|
||||||
import ezodf
|
import ezodf
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
from .tools import sanitize_df
|
||||||
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()))
|
|
||||||
|
|
||||||
|
|
||||||
def load_ods(doc, sheet, headers=True, columns=None):
|
def load_ods(doc, sheet, headers=True, columns=None):
|
||||||
|
|
@ -52,25 +45,6 @@ def load_ods(doc, sheet, headers=True, columns=None):
|
||||||
return df
|
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):
|
def read_ods(file_or_path, sheet, headers=True, columns=None):
|
||||||
"""
|
"""
|
||||||
This function reads in the provided ods file and converts it to a
|
This function reads in the provided ods file and converts it to a
|
||||||
|
|
@ -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
|
||||||
6
setup.py
6
setup.py
|
|
@ -1,7 +1,7 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
|
||||||
VERSION = "0.0.2"
|
VERSION = "0.0.3"
|
||||||
|
|
||||||
setup(name="pandas_ods_reader",
|
setup(name="pandas_ods_reader",
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
|
|
@ -9,7 +9,7 @@ setup(name="pandas_ods_reader",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 3 - Alpha',
|
'Development Status :: 3 - Alpha',
|
||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: MIT License',
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.7',
|
||||||
'Topic :: Utilities',
|
'Topic :: Utilities',
|
||||||
],
|
],
|
||||||
keywords='data io pandas ods',
|
keywords='data io pandas ods',
|
||||||
|
|
@ -19,5 +19,5 @@ setup(name="pandas_ods_reader",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
install_requires=["ezodf", "pandas"]
|
install_requires=["ezodf", "pandas", "lxml"]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue